首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在我的脚本中在ssh进入DC的时钟服务器后有一个脚本触发器?

如何在我的脚本中在ssh进入DC的时钟服务器后有一个脚本触发器?
EN

Stack Overflow用户
提问于 2018-07-01 08:00:40
回答 1查看 129关注 0票数 0

所以,我有一个剧本,它的目的是:

  1. 询问DC号码和时钟号。
  2. 登录到上述DC的时间时钟服务器。
  3. 登录后,它打算在我的脚本中运行一个独立的脚本,它更新上面提到的时钟号。

我的问题是,一旦触发脚本,它就会按预期的方式登录到服务器,提示我输入用户ID,然后当"xterm“出现时,我必须按下"enter”。在此之后,应该运行更新脚本,但是它没有运行,并且位于命令行。

退出服务器后,它将运行更新脚本,但是失败,因为更新脚本不存在于跳转框中。

我的问题是,在脚本登录到服务器之后,我如何才能让它触发时钟服务器内部的脚本,就像我想要的那样?谢谢。

脚本如下:

代码语言:javascript
复制
#!/bin/bash -x
export LANG="C"

####
####
## This script is intended to speed up the process to setup timeclocks from DC tickets
## Created by Blake Smreker | b0s00dg | bsmreker@walmart.com
####
####

#Asks for DC number

echo "What is the four digit DC number?"

read DC         #User input

#Asks for Timeclock number

echo "What is the two digit Timeclock number?"

read TMC        #User input

#Defines naming convention of tna server

tnaserver="cs-tna.s0${DC}.us.wal-mart.com"

#creating variable to define the update script

tcupd="/u/applic/tna/shell/tc_software_update.sh tmc${TMC}.s0${DC}.us REFURBISHED"

#Logging in to the cs-tna package at the specified DC

/usr/bin/dzdo -u osedc /bin/ssh -qo PreferredAuthentications=publickey root@$tnaserver

echo "Preforming Timeclock update on Timeclock=$TMC, at DC=${DC}"

echo ""

echo "-----------------------------------------------------------------------------------------------------------------------------------------"

$tcupd #Runs update script

echo "-----------------------------------------------------------------------------------------------------------------------------------------"

echo ""

sleep 2

echo "If prompted to engage NOC due to Timeclock not being on the network, send the ticket to DC Networking"

echo ""

echo "OR"

echo ""

echo "If the script completed successfully, and the Timeclock was updated, you can now resolve the ticket"
EN

回答 1

Stack Overflow用户

发布于 2018-07-01 12:43:18

您必须在ssh会话中运行命令,而不是在它之后运行:

代码语言:javascript
复制
echo "Preforming Timeclock update on Timeclock=$TMC, at DC=${DC}"

echo ""

echo "-----------------------------------------------------------------------------------------------------------------------------------------"

###### $tcupd #Runs update script
/usr/bin/dzdo -u osedc /bin/ssh -qo PreferredAuthentications=publickey root@$tnaserver /bin/bash -c /u/applic/tna/shell/tc_software_update.sh tmc${TMC}.s0${DC}.us REFURBISHED

echo "-----------------------------------------------------------------------------------------------------------------------------------------"

echo ""

sleep 2

echo "If prompted to engage NOC due to Timeclock not being on the network, send the ticket to DC Networking"

echo ""

echo "OR"

echo ""

echo "If the script completed successfully, and the Timeclock was updated, you can now resolve the ticket"

曼什你可以看到ssh [-46AaCfGgKkMNnqsTtVvXxYy] ....... destination [command]。如果不给[command],ssh将运行远程登录命令脚本,例如xterm。你可以阅读更多的这里这里,或者浏览谷歌。

您需要考虑如何以及希望传递给远程机器的环境变量,并记住如何正确地封装这些变量,以便在您或远程计算机上展开这些变量。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51121476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档