Check if remote files exist (shell script)
Posted on 2008-10-20
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/export/wpubon/processado/WPUBON01*'" >/dev/null'; then
echo "file '"/home/tplinux/SAPiDoc/export/wpubon/processado/WPUBON01*"' exists";
echo "file '"/home/tplinux/SAPiDoc/export/wpubon/processado/WPUBON01*"' doesn't exist";
but I got the following error:
ls: /home/tplinux/SAPiDoc/export/wpubon/processado/WPUBON01*: No such file or directory
file '/home/tplinux/SAPiDoc/export/wpubon/processado/WPUBON01*' doesn't exist
The problem seems to be finding a remote command that accepts wildcards.
Any help would be appreciated.