所以,我有一个剧本,它的目的是:
我的问题是,一旦触发脚本,它就会按预期的方式登录到服务器,提示我输入用户ID,然后当"xterm“出现时,我必须按下"enter”。在此之后,应该运行更新脚本,但是它没有运行,并且位于命令行。
退出服务器后,它将运行更新脚本,但是失败,因为更新脚本不存在于跳转框中。
我的问题是,在脚本登录到服务器之后,我如何才能让它触发时钟服务器内部的脚本,就像我想要的那样?谢谢。
脚本如下:
#!/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"发布于 2018-07-01 12:43:18
您必须在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"从曼什你可以看到ssh [-46AaCfGgKkMNnqsTtVvXxYy] ....... destination [command]。如果不给[command],ssh将运行远程登录命令脚本,例如xterm。你可以阅读更多的这里或这里,或者浏览谷歌。
您需要考虑如何以及希望传递给远程机器的环境变量,并记住如何正确地封装这些变量,以便在您或远程计算机上展开这些变量。
https://stackoverflow.com/questions/51121476
复制相似问题