所以,我有一个脚本,其目的是:
询问DC编号和时间时钟编号
登录上述DC的时间时钟服务器
登录后,它打算在我的脚本中运行一个单独的脚本,该脚本将更新上述的时钟编号。
我的问题是,一旦触发脚本,脚本便会按预期方式登录到服务器,提示我输入用户ID,然后在出现“ xterm”时必须按“输入”。之后,应该运行更新脚本,但是不会运行更新脚本,它位于命令行中。
退出服务器后,然后它将运行更新脚本,但是失败,因为跳转框中不存在更新脚本。
我的问题是,在脚本登录到服务器后,我如何才能使它触发Time Clock服务器中的脚本?谢谢。
脚本如下:
#!/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"
答案 0 :(得分:1)
您必须在ssh会话中而不是在此之后运行命令:
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"
在man ssh中,您看到ssh [-46AaCfGgKkMNnqsTtVvXxYy] ....... destination [command]
。如果未提供[command]
,则ssh运行远程登录命令脚本,例如xterm。您可以阅读更多here或here或只是浏览google。
您需要考虑如何以及将哪个环境变量传递给远程计算机,并记住正确封装这些变量,以使它们在您或远程计算机上得到扩展。