
SSH 스크립트의 명령줄 아래에 있는 쉘 스크립트의 매개변수를 전달해야 합니다.
예를 들어 :
#!/usr/bin/expect
spawn ssh [email protected] "cm1+passingparameters.sh;cmd2"
123.sh
잘 작동하는 기존 스크립트입니다 .
#!/usr/bin/expect
spawn ssh [email protected] "/pstools/85419/jre/bin/java -Xms1024M -Xmx1024M -Dhttps.protocols=TLSv1.2 -Djdk.tls.client.protocols=TLSv1.2 -jar /app1/non/psoft/85419/gu1/gust/classes/SVC_TestS.jar https://decorp6-- tst4.custhelp.com/services/rest/connect/v1.3/incidents userid password ssow.proxy.com port;cd /app01/nonhr/psoft/85419/gucq1/gecust;mail -s 'OTO' [email protected] < logs.txt"
expect "password"
send "mypassword\r"
interact
expect eof
나는 2개의 스크립트를 원 a.sh
하고b.sh
a.sh
다음과 같아야 합니다(위에서 언급한 원본 스크립트의 변경 사항에 유의하세요 PASS b.sh after .jar
).
#!/usr/bin/expect
spawn ssh [email protected] "/pstools/85419/jre/bin/java -Xms1024M -Xmx1024M -Dhttps.protocols=TLSv1.2 -Djdk.tls.client.protocols=TLSv1.2 -jar /app1/non/psoft/85419/gu1/gust/classes/SVC_TestS.jar PASS b.sh;cd /app01/nonhr/psoft/85419/gucq1/gecust;mail -s 'OTO' [email protected] < logs.txt"
expect "password"
send "mypassword\r"
interact
expect eof
b.sh
다음과 같아야합니다
#!/user/ksh
https://decorp6--tst4.custhelp.com/services/rest/connect/v1.3/incidents userid password ssow.proxy.com port
답변1
나생각하다원격 java
명령에 다양한 인수를 삽입하는 방법을 묻는 질문이 있습니다. 이는 다음과 같이 간단할 수 있습니다.
#!/usr/bin/expect
if {[llength $argv] == 0} {
puts stderr "Usage: todo fixeme"
exit 1
}
set the_args [join $argv]
spawn ssh [email protected] "/pstools/85419/jre/bin/java ... -jar /app1/non/psoft/85419/gu1/gust/classes/SVC_TestS.jar $the_args; ..."
...
그런 다음 다음과 같은 방법을 통해 위의 내용을 실행합니다.
$ whatyousaveditas https://decorp6--tst4.cu... user pass ...