cmdshell run cd

24 views
Skip to first unread message

Bogdan Dumitrica

unread,
Dec 19, 2012, 5:06:30 AM12/19/12
to boto-...@googlegroups.com
Hi,

I just noticed that running the following code (assuming that there is an instance running and that instance_cmd is a cli handler to the instance)

instance_cmd.run("cd my_dir")
instance_cmd.run("pwd")

will return the home dir of the user I logged in with as cwd and not the dir I  just changed to...

Is there a way to make the cd command effects persistent over multiple run calls? 

Thanks,

--
BOGDAN
     

Mitchell Garnaat

unread,
Dec 19, 2012, 7:55:53 AM12/19/12
to boto-...@googlegroups.com
Hi -

The "run" command is simply executing the specified command on the remote instance.  It is possible to execute multiple commands on one command line by concatenating them with "&&", as it:

instance_cmd.run("cd my_dir && pwd")

I'm not sure if that accomplishes what you want or not.

Mitch

--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To post to this group, send email to boto-...@googlegroups.com.
To unsubscribe from this group, send email to boto-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/boto-users?hl=en.

Bogdan Dumitrica

unread,
Dec 19, 2012, 7:59:45 AM12/19/12
to boto-...@googlegroups.com
Hi,

It does. That's the solution I'm using, but I was wondering if there's another way to do it.

Thanks,

Bogdan
--
  _ )                   |              
  _ \   _ \   _` |   _` |   _` |    \  
 ___/ \___/ \__, | \__,_| \__,_| _| _| 
            ____/                                     

Beto Meijome

unread,
Jan 10, 2013, 9:34:24 PM1/10/13
to boto-...@googlegroups.com
put all your commands in a script ? your env is being reset (new shell) for each _cmd.run .

b

--
Norberto 'Beto' Meijome
Snr. Systems Engineer | Freelancer.com

Patrick Dunnigan

unread,
Jan 10, 2013, 9:58:53 PM1/10/13
to boto-...@googlegroups.com
try something similar to the following (caveat: untested but should work assuming $SHELL is something like /bin/bash) ...

script = """$SHELL <<EOF
cd $HOME
pwd
ls -l
export MYFILE=/tmp/myfile
echo "barf" > $MYFILE
cat $MYFILE
rm $MYFILE
touch /tmp/afiletomakesurethisworked
EOF"""

instance_cmd.run(script)

Patrick


Patrick Dunnigan

Chief Architect

Cloud Sidekick


Cloudsidekick.com
Twitter: @dunniganp
Reply all
Reply to author
Forward
0 new messages