Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > output from external commands

Reply
Thread Tools

output from external commands

 
 
James Colannino
Guest
Posts: n/a
 
      10-24-2005
Hey everyone. First off, I'm new to the list. I had had a little bit
of experience with Perl before discovering Python. The more Python I
learn, the more I love it I just have a quick question to ask. I
know that this is probably a simple question, but I've been googling
around, and partly because I'm not sure exactly what to search for, I've
been unsuccessful at finding an answer. What I'd like to do is be able
to take the output of an external command and assign it as an array of
strings. So, for example, in Perl I could do something like:

@files = `ls`;

So I guess I'm looking for something similiar to the backticks in Perl.
Forgive me if I've asked something that's a bit basic for this list.
Any help would be greatly appreciated Thanks very much in advance.

James

--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/


 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      10-24-2005
James Colannino <(E-Mail Removed)> writes:

> Hey everyone. First off, I'm new to the list. I had had a little bit
> of experience with Perl before discovering Python. The more Python I
> learn, the more I love it I just have a quick question to ask. I
> know that this is probably a simple question, but I've been googling
> around, and partly because I'm not sure exactly what to search for,
> I've been unsuccessful at finding an answer. What I'd like to do is
> be able to take the output of an external command and assign it as an
> array of strings. So, for example, in Perl I could do something like:
>
> @files = `ls`;
>
> So I guess I'm looking for something similiar to the backticks in
> Perl. Forgive me if I've asked something that's a bit basic for this
> list. Any help would be greatly appreciated Thanks very much in
> advance.


This is a scripting language feature. Python doesn't have direct
support for it, any more than C++ does. To get that functionality, you
want to use either the os.popen function, or - preferable, but only
available in newer Pythons - the subprocess module.

<mike
--
Mike Meyer <(E-Mail Removed)> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
 
James Colannino
Guest
Posts: n/a
 
      10-24-2005
Mike Meyer wrote:

>This is a scripting language feature. Python doesn't have direct
>support for it, any more than C++ does. To get that functionality, you
>want to use either the os.popen function, or - preferable, but only
>available in newer Pythons - the subprocess module.
>
>


Thanks.

James

--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [OT] Re: output from external commands Terry Hancock Python 2 10-26-2005 12:53 AM
[OT] Re: output from external commands darren kirby Python 2 10-25-2005 03:42 AM
Re: output from external commands darren kirby Python 6 10-24-2005 09:14 PM
capturing the output of external commands Avi Kak Python 4 07-26-2004 03:16 AM
Re: man pages for C commands (GCC commands) Ben Pfaff C Programming 4 06-28-2003 06:21 PM



Advertisments