wget -O creates a empty file on failure
Hi All,
I am trying to check in the if condition that "some file" exists in the repository or not like below: if (wget -O /path/ $REPO_URL); then do operation fi my purpose is, if the file is present then do wget and perform some operation on that. this is working well if the file is present however if it is not present in the repository wget creates an empty file. how can i prevent this and what are my options? Regards, Chetan Jain. |
You can check the return value of 'wget':
Code:
wget -O /path/ $REPO_URL |
...next to the return value of wget you can also check the size of the output file (see 'man test' and increase mana for using 'mktemp'):
Code:
goNoGo() { _TMPFILE=`mktemp -p /tmp wget.XXXXXXXXXX` && { Code:
goNoGo $REPO_URL && do operation |
All times are GMT -5. The time now is 12:48 PM. |