On Wed, Jan 7, 2009 at 5:09 PM, Sander Sweers <sander.swe...@gmail.com>wrote:
> On Wed, Jan 7, 2009 at 22:04, Kayvan Sarikhani <ksarikh...@gmail.com> > wrote: > > > > This is of course not a Python error, but as you might guess from looking > at > > the script, the whole $SERVER_NAME piece is probably wrong. > > Indeed the variables are wrong > Right...I thought so, but wasn't sure if there was any kind of equivalent within Python...couldn't hurt to try. :) > Almost, look at the below session in idle. The %s are replaced by the > variables servername and logname. See string formatting [1] for more > info. > > >>> servername = 'testserver' > >>> logname = 'logname' > >>> print 'rosh -m %s -l %s' % (servername, logname) > rosh -m testserver -l logname > > So you need to use something like below in your loop. > > roshCommand = 'rosh -m %s -l %s' % (servername, logname) > > os.system(roshCommand) > > I do not see the servername variable being assigned a value in your > script so the above will fail. I assume it will be something like > > logname = '/var/log/somelogfile' > > You might want to look at the subprocess module as this gives you a > lot more control but is also more complicated. > > Greets > Sander > > [1] > http://docs.python.org/library/stdtypes.html#string-formatting-operations > Yes, it did fail...rosh needs the full path or the -n identifier to remote shell into the VM's, and you're right that it didn't find it. As for the $LOGNAME variable, that piece works for identifying the username which is what I needed for that...it doesn't actually point to a log file or the like. If I misunderstood what you meant, my apologies. Thanks very much though, this is also a lot of help and definitely points me in the right direction. I'll certainly check out string formating and see where I can go from there. I did look at the subprocess module but I'm still not sure I understand it...seems to have a lot of options and is flexible, but I still need to examine how it's used. Thanks! Kayvan
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor