help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] script with ssh and filenames with spaces


From: Matthew Cengia
Subject: Re: [Help-bash] script with ssh and filenames with spaces
Date: Thu, 18 Jul 2013 09:58:12 +1000
User-agent: K-9 Mail for Android

Gscantlen,

Please paste the entire terminal output including both the exact command(s) you 
ran, as well as their output. I also strongly recommend dropping by the #bash 
channel on Freenode if you haven't already; we'llbe able to help you there, 
probably with a quicker turn-around time. I expect you should be running the 
following:

#! /bin/bash 

PARAMS_FOR_LS=(-alst "dir with spaces") 

# get directory of local system 
ls "address@hidden" 

hosts=(host1 host2 host3)

# get directory of remote systems 
for host in "address@hidden"; do
  echo ls "address@hidden" | ssh "$host"
done


I don't know what you mean by "do search 'x' for a hostname; get host1"; 
perhaps I'm missing something here.

address@hidden wrote:

>
>
>plz help with this script, 
>
>I wish to ssh this command to several hosts: 
>ls -alst "dir with spaces" 
>
>This script is close but I need DOUBLE-quotes around the remote
>commands 
>#! /bin/bash 
>
>PARAMS_FOR_LS=(-alst "dir with spaces") 
>
># get directory of local system 
>ls "address@hidden" 
>
># get directory of remote systems 
>
>#do search 'x' for a hostname; get host1 
>ssh host1 ls "address@hidden" 
>
>#do search 'y' for a hostname; get host2 
>ssh host2 ls "address@hidden" 
>
>#do search 'z' for a hostname; get host3 
>ssh host3 ls "address@hidden" 
>
>
>I have tried several variations of eval and echo. 
>plz help 
>
>
>
>Greg, 
>your Cc did not contain my question. 
>I was not able to use your answer. 
>I get the following: 
>+ ssh ccn000 bash 'ls "address@hidden"' EOF 
>/bin/ls: /bin/ls: cannot execute binary file 
>
>
>----- Original Message -----
>From: "Greg Wooledge" <address@hidden> 
>To: address@hidden 
>Cc: address@hidden, address@hidden 
>Sent: Wednesday, July 17, 2013 2:52:11 PM 
>Subject: Re: script with ssh and filenames with spaces 
>
>On Wed, Jul 17, 2013 at 08:42:17PM +0000, address@hidden wrote: 
>> I wish to ssh this command to several hosts: 
>> ls -alst "dir_with_spaces" 
>
>for host in "address@hidden"; do 
>ssh "$host" bash <<-'EOF' 
>ls -alst "your directory" 
>EOF 
>done 
>
>The - in front of the here document's delimiter allows indentation with
>
>tabs only (not spaces). 
>
>I Cc'ed address@hidden because that's more appropriate for this 
>question. 

-- 
Sent from my phone. Please excuse my brevity.
Regards,
Matthew Cengia



reply via email to

[Prev in Thread] Current Thread [Next in Thread]