-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is probably either very simple or impossible. If I have a script (Perl, Python, whatever), is it possible to execute an external command (say, tar - -vt) and pipe the output from stdout into the script I'm currently running? I don't see the syntax to do it, but I figured the gurus here would no for sure. tia - ---Michael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/Ul0jjeziQOokQnARAgjEAJkBo7TqT5hChrGoE74gessxCnFtcQCdG3AJ yKa8kZlYic+LwtZhr0HRwqU= =8JAS -----END PGP SIGNATURE-----
On Sun, Aug 31, 2003 at 03:40:02PM -0500, Michael Satterwhite wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
This is probably either very simple or impossible. If I have a script (Perl, Python, whatever), is it possible to execute an external command (say, tar - -vt) and pipe the output from stdout into the script I'm currently running? I
In perl, use something like: open FOO, "tar tv some.tar|"; while (<FOO>) { ... } HTH, -Kastus
This is probably either very simple or impossible. If I have a script (Perl, Python, whatever), is it possible to execute an external command (say, tar - -vt) and pipe the output from stdout into the script I'm currently running? I don't see the syntax to do it, but I figured the gurus here would no for sure.
tia - ---Michael
I can't tell you exactly how to do that, but I can tell you a work around that I used. In python I used the system() method to run a command, eg. system("ls -la > /tmp/ls.txt") redirecting it into /tmp/ls.txt as shown. Then I open the file using python, parse it, and then delete it when I'm done. For my project this was fine as the file it made in tmp was extremely small ( > 1k).
participants (3)
-
Kastus
-
Michael Sacco
-
Michael Satterwhite