outputting a command to the terminal?

John Salerno johnjsal at NOSPAMgmail.com
Sun Aug 13 20:21:26 EDT 2006


Yu-Xi Lim wrote:

> I assume you're using a Debian-based distro with aptitude as the front 
> end. In which case, all dpkg operations should be logged in 
> /var/log/dpkg.log

Yes, I'm using Ubuntu. But I checked this log file and I'm a bit 
confused. It has a lot of listings for 5-31-06, but I didn't even 
install Linux until last Saturday. The next date after 5-31 is 8-5-06, 
and I know I installed things between last Saturday and Aug. 5.

(But this is OT, so don't worry about it.)

> I'm wondering about the need to "output the bash command to the 
> terminal". It would probably suffice if your Python script just spawned 
> an instance of the shell with the necessary command line. Take a look at 
> the subprocess module.
> 
> But this really calls for a bash script:
> 
> #!/bin/bash
> echo $@ >> /path/to/manual_install.log
> sudo aptitude install $@
> 
> 
> Shorter than the equivalent Python code. You could probably declare this 
> as a function in your bash initialization files too, if you know how to 
> do this.

Hmm, interesting. I figured I could do this with a bash script, but I 
don't know bash at all and I'm trying to stick with Python. I don't 
quite understand your bash script (not familiar with the $@ syntax).

I think I'll take a look at the subprocess module, just for fun. :)



More information about the Python-list mailing list