簡體   English   中英

ssh進入DC的時間時鍾服務器后,如何在腳本中觸發腳本?

[英]How to have a script trigger in my script after it ssh's into a DC's Time clock server?

因此,我有一個腳本,其目的是:

  1. 詢問DC號和時鍾號

  2. 登錄上述DC的時鍾服務器

  3. 登錄后,它打算在我的腳本中運行一個單獨的腳本,該腳本將更新上文所述的時鍾編號。

我的問題是,一旦觸發腳本,腳本便會按預期登錄服務器,提示我輸入用戶ID,然后在出現“ xterm”時必須按“輸入”。 之后,應該運行更新腳本,但是不會運行更新腳本,它位於命令行中。

我退出服務器后,然后它將運行更新腳本,但失敗,因為跳轉框中不存在更新腳本。

我的問題是,腳本登錄到服務器后,如何如我所願地在時鍾服務器內部觸發腳本? 謝謝。

腳本如下:

#!/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會話中而不是在以下命令中運行命令:

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。 您可以在此處此處閱讀更多信息 或者只是瀏覽google。
您需要考慮如何以及將哪種環境變量傳遞給遠程計算機,並記住正確封裝這些變量,以使它們在您或遠程計算機上得到擴展。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM