Re: Passing variables to remote hosts through ssh
- From: Unruh <unruh-spam@xxxxxxxxxxxxxx>
- Date: 19 May 2006 23:40:38 GMT
Earthdog <nobody@xxxxxxxxxx> writes:
Hi,
I have a central administration server that has root-level public key
access to my other hosts. I run scripts that use ssh to execute commands
on all my hosts. How do I pass variables through ssh?
For example, suppose I want to create a directory called /tmp/newdir on
100 hosts:
#/bin/ksh
DIRNAME=newdir
for i in `cat /long/list/of/hosts`
do
ssh $i '/usr/bin/mkdir /tmp/$DIRNAME'
done
This doesn't work, because $DIRNAME doesn't get passed to the remote host.
How can I make it work without hardcoding newdir in the ssh line?
change the ' to "
' says do not expand the stuff inside. " says do expand the stuff inside So
if you do
ssh $i "/usr/bin/mkdir /tmp/$DIRNAME"
the $DIRNAME will be expanded to newdir on the local machine.
Thanks..
- References:
- Passing variables to remote hosts through ssh
- From: Earthdog
- Passing variables to remote hosts through ssh
- Prev by Date: Re: Passing variables to remote hosts through ssh
- Next by Date: Re: Changing keys
- Previous by thread: Re: Passing variables to remote hosts through ssh
- Next by thread: tunneling skype w/ ssh on PDA
- Index(es):
Relevant Pages
|
|