The below while loop is in ksh on a SunOs server: SPARC-Enterprise 5.10
The ksh version is: Version M-11/16/88i
The intention of the below while loop is to read through a list of file names in files.txt and
delete each file from a server, one at a time. The delete works, the problem is that if a file
does not exist the loop exits instead of issuing the read for the next file. The first file name
in files.txt does not exist, purposely to allow testing the routine for file not present.
Interestingly if the ssh cmd is removed and replaced with the execution of a non-existent
script the loop does not exit, it reads all files in files.txt. Why does the loop exit when ssh
tries to delete a file not on the server? I have tried various versions of trap with no success.
There is no break or exit in the script, which contains only the while loop.
Thanks, Lee
Last edited by Scott; 08-14-2013 at 04:26 PM..
Reason: Removed formatting
Through a LOT of trial and error and researching on the net I came across the below while loop syntax just a little while ago, the first example below. I changed my while loop to match and it works yet I do not understand why it works. The echo of $? after each ssh “rm” failure is 1 as it should be because the files do not exit. I am testing the error condition for when a file does not exist. I would like to understand the reason the syntax works. The previous while loop after the first file rm failure had control go back to the read and then the script stopped; I used “set -xv”. It was as if the “rm” failure triggered an EOF.
I have two linux servers viz 12.7.44.18 and 12.7.45.18
I wish to ssh from both these server to a destination AiX server 12.7.33.18
The ssh works from 12.7.44.18 -> 12.7.33.18 but fails from 12.7.45.18 -> 12.7.33.18
The openssl version on both linux source 12.7.44.18 and 12.7.45.18 is the... (7 Replies)
I have two users on dest_host server viz wlsadm & wasadm.
From src_host server with root user I m able to passwordless login to wlsadm@dest_host however, the same fails for wasadm@dest_host
Below is the debug for both first the working ssh and then the non-working ssh.
Works:
... (6 Replies)
I have a constraint to follow organization policy. So i do not have much liberty.
ssh -i /opt/nonprod user1@hostone -t bash works while ssh -i /opt/nonprod -t bash user1@hostone fails
How can I get this to work when I am enforced to put -t bash before the user@hostname ?
Will share debug... (3 Replies)
Hi,
I am triggering a windows exe file using the below command.
ssh user@remoteserver command.exe -option1:xx /option2:yy
This command is working fine from windows command prompt. When I am triggering the same command from ssh I get the error message cant load
Any ideas to deal with... (2 Replies)
Unable to set ssh passwordless authentication
I am unable to ssh with passwordless authentication from Windows client onto UBuntu server. The ssh version on UBuntu is OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e , while SSH on Windows Client is OpenSSH_5.1p1, OpenSSL 0.9.8k. I turned on ssh... (5 Replies)
I'm trying to write a script using expect. I'd like the script to execute several commands when the ssh succeeds and i want it to exit if the ssh fails. Does this require to define a time out for the ssh command so that if the prompt is back before this defined time the next commands are executed??... (2 Replies)
i have a script like below, i am trying to print "...." until a background process that was executed before is running,, the below does work and teh loop keeps on printing "..", can someone help where i am wrong.
/tmp/test/abc.sh &
until
do
echo "..\c"
done
abc.sh is the scipt... (8 Replies)
I'm trying to run a set of commands on a remote machine using ssh in a shell script. One of the commands is unzip. But when the execution reaches this command, the script fails with an error that unzip is not found. Below is the code and the error snippet.
sourceDir=$1 ; filename=$3 ; destDir=$2... (4 Replies)
hi all,
i have a while loop which i am using to read lines into an array:
k=0
exec 10<file
while read LINE <&10; do
ARRAY=$LINE
((k++))
done
exec 10>&-
echo ${ARRAY}
for some reason when i display the array it is not showing the last row in the file.
any help appreciated. (1 Reply)
hi
i have two files
cat input.txt
123456| 43256
456482|5893242
cat data.txt
xv 123456 abcd dsk
sd 123456 afsfn dd
df 43256 asdf ff
ss 456482 aa
sf 5893242 ff ff
aa 5893242 aa aa
i need to read inputs from input.txt and find data for data.txt.
then i need to print them as a... (2 Replies)