Reputation: 702
trying to run this command locally in a batch file gives an expected result
find $DIR -name "*" -type f -exec ls -alo {} \; | awk '{printf "%-12s %-1s %-1s %-1s %-1s \n",$4,substr($8,20),$9,$10,$11}' | sort -k 1 -n > file_count
when I run the batch file remotely via ssh, the command breaks:
+ find /cygdrive/h/AltaroHyperVBackup -name '*' -type f -exec ls -alo '{}' ';'
+ awk '{printf "%-12s %-1s %-1s %-1s %-1s \n",$4,substr($8,20),$9,$10,$11}'
**FIND: Invalid switch**
How should I code the batch file so that it runs correctly when called remotely?
Upvotes: 1
Views: 912
Reputation: 21
Alternatively, you could also put this near the top of your batch file:
export PATH=/bin/:/usr/bin:$PATH
This will ensure that the Cygwin find, not the Windows find, gets called, per shellter's correct diagnosis.
Upvotes: 2
Reputation: 1722
I found if you put quotes around the find it works. make the first part of your command this:
ssh NODE "find $DIR -type f -exec ls -alo {} \\; "
I got rid of the -name "*" because I believe that is redundant.
Upvotes: 0