0

I want to execute a script which is located on different machines. On each machine there is a set of files which the script should scan. I have something like this but it does not work:

for host in machine{11..14}; do ssh -q user@$host; 
    for i in $(ls -1 ~/current/nohup_node_?.out_202407*); 
    do   ~/bin/duration.sh $i; 
    done; 
done

the command just logins but doesn't find the file:

ls: cannot access '../nohup_node_?.out_202407??_??': No such file or directory
7
  • 2
    1) I suggest to replace for i in $(ls ...) with for i in ~/.... 2) The error doesn't really match the path given in the script. If you log onto one of these machines, does the ls work? 3) It might be worth looking into ansible. Commented Jul 25, 2024 at 8:31
  • there is no problem with the ls. I used this on one particular file only and it worked fine: Commented Jul 25, 2024 at 9:00
  • This command worked fine: for host in machine{11..14};do ssh -q user@${host} "printf '%-15s' $host; ~/bin/duration.sh ~/current/nohup_node_?.out";done Commented Jul 25, 2024 at 9:03
  • 2
    You are using different paths everywhere: ~/current/nohup_node_?.out_202407*, ../nohup_node_?.out_202407??_?? or ~/current/nohup_node_?.out. So what is it now? Commented Jul 25, 2024 at 9:05
  • 3
    Are you expecting the inner for loop to run on the remote machine? Commented Jul 25, 2024 at 11:20

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.