Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Substitution 1

Status
Not open for further replies.

khalidaaa

Technical User
Jan 19, 2006
2,323
BH
Hi Guros,

I'm trying to write a script to remotely backup a directory on another server (tied by ssh)

When I do the following it doesn't work:

Code:
tape=$(ssh Machine2 lsdev -C | grep rmt | grep Ultr | cut -d' '  -f1)
ssh Machine2 eval 'cd /; find /bkup \
                       -print | backup -iqf/dev/$tape.1'

But when i do it this way it works:

Code:
ssh Machine2 'cd /; find /bkup \
                       -print | backup -iqf/dev/rmt1.1'

Any idea What should be done to make it working using the first command?

Regards,
Khalid
 
Hello,

I don't think that one can determine what is going wrong without seeing the output of lsdev command one your remote machine.
But you should be able to find out yourself by playing around with commands like this:
ssh Machine2 lsdev -C | grep rmt | grep Ultr | cut -d' ' -f1
My guess is that it will not give rmt1.

And why do you need 'eval', by the way?
Did you try without it?
 
I checked the command first and it gave me rmt1!

But i have a doubt that the substitution happeneds after the command run or something like that! so the backup won't happen.

The strange thing is that there is no errors!

I just read the tape after doing so and i don't have the data!

(You have forget about eval :p I was playing around)

Thanks for the reply hoinz

Regards,
Khalid
 
ok then, another idea:
try with " instead of ' :
Code:
ssh Machine2 "cd /; find /bkup \
                       -print | backup -iqf/dev/rmt1.1"
 
sorry, should have been:
Code:
ssh Machine2 "cd /; find /bkup \
                       -print | backup -iqf/dev/$tape.1"
 
Oh yeah that did it.

Star deserved.

Regards,
Khalid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top