outputting a command to the terminal?
Yu-Xi Lim
yuxi at ece.gatech.edu
Sun Aug 13 17:56:08 EDT 2006
John Salerno wrote:
> 1. First of all, does Linux keep track of the packages you manually
> install? If so, then I won't have to do this at all.
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
Generally, after the initial installation, all subsequent operations are
either updates of existing packages or packages you installed manually.
Only rarely do you get new packages installed automatically as a result
of an additional dependency from an original automatically installed
package.
If you know when you completed your initial installation, you can easily
parse the log files to determine what else was installed after that.
> 2. Assuming I write this, how do output the bash command to the
> terminal? Is there a particular module that Python uses to interact with
> the terminal window that I can use to send the install command to the
> terminal?
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.
More information about the Python-list
mailing list