the following script "testssh.ksh" proves that ssh have some problems when we try to perform ssh from multiple machines on the same time
in fact the target of this script is to verify the file test_file under /var/tmp in the Solaris server (10.10.18.6) , as all see in some ssh steps we can’t verify the existing of the test_file because ssh stuck or not activate from the expect
background - this script perform 15 times ssh to Solaris server with IP - 10.10.18.6 on the same time in order to verify the file_test under /var/tmp in the server
my question - how to improve the ssh process in order to avoid the following problems
Remark - sleep can help us in this situation - but I not want to add sleep before ssh process
[root@linux /var/tmp]# more testssh.ksh
#!/bin/ksh
expect=`cat << EOF
set timeout -1
spawn ssh 10.10.18.6
expect {
")?" { send "yes\r" ; exp_continue }
word: {send pass123\r}
}
expect > {send "ls /var/tmp/test_file\r"}
expect > {send exit\r}
expect eof
EOF`
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
( expect -c "$expect" | grep "test_file" | grep -v ls ) &
done
example - when we run the script testssh.ksh
[root@linux /var/tmp]# /var/tmp/testssh.ksh
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file