gpt4 book ai didi

linux - 在 ssh 进入 DC 的时钟服务器后,如何在我的脚本中触发脚本?

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:45 25 4
gpt4 key购买 nike

所以,我有一个脚本,它的预期目的是:

  1. 询问DC号码和时钟号码

  2. 登录上述DC的时钟服务器

  3. 登录后,我打算在我的脚本中运行一个单独的脚本来更新上面提到的时钟编号。

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

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

我的问题是,在脚本登录到服务器后,我怎样才能让它触发时钟服务器内的脚本,正如我所希望的那样?谢谢。

脚本如下:

#!/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"

最佳答案

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

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。您阅读更多 herehere 或只是浏览 google。
您需要考虑要如何以及将哪个环境变量传递给远程计算机,并记住正确封装变量,以便它们在您或远程计算机上得到扩展。

关于linux - 在 ssh 进入 DC 的时钟服务器后,如何在我的脚本中触发脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51121476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com