rmdb
asked on
Check if remote files exist (shell script)
Hello.
I've already searched, but found nothing...
I need a script that checks if remote file exists. Everything that I've found only relates to one particular file. I need to check if there are any files in a particular directory, that start by some string...
I've tried this, unsuccessfully:
if ssh -l "$USER" $POSM200 'ls "'/home/tplinux/SAPiDoc/ex port/wpubo n/processa do/WPUBON0 1*'" >/dev/null'; then
echo "file '"/home/tplinux/SAPiDoc/ex port/wpubo n/processa do/WPUBON0 1*"' exists";
exit;
else
echo "file '"/home/tplinux/SAPiDoc/ex port/wpubo n/processa do/WPUBON0 1*"' doesn't exist";
fi
but I got the following error:
ls: /home/tplinux/SAPiDoc/expo rt/wpubon/ processado /WPUBON01* : No such file or directory
file '/home/tplinux/SAPiDoc/exp ort/wpubon /processad o/WPUBON01 *' doesn't exist
The problem seems to be finding a remote command that accepts wildcards.
Any help would be appreciated.
I've already searched, but found nothing...
I need a script that checks if remote file exists. Everything that I've found only relates to one particular file. I need to check if there are any files in a particular directory, that start by some string...
I've tried this, unsuccessfully:
if ssh -l "$USER" $POSM200 'ls "'/home/tplinux/SAPiDoc/ex
echo "file '"/home/tplinux/SAPiDoc/ex
exit;
else
echo "file '"/home/tplinux/SAPiDoc/ex
fi
but I got the following error:
ls: /home/tplinux/SAPiDoc/expo
file '/home/tplinux/SAPiDoc/exp
The problem seems to be finding a remote command that accepts wildcards.
Any help would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Any reason for the B grade?
ASKER
Hi,
Sorry, no reason at all. I was filling the "accept solution", and put B instead of A, I was distracted... Any chance to change it?
Sorry, no reason at all. I was filling the "accept solution", and put B instead of A, I was distracted... Any chance to change it?
You have to put an admin request in.
wildcards are not your problem.
You have way too much ' s and " s in your ssh command.
Leave them all out and escape your asterisk with a \.
w