plz help how to print python variable using os.system()

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

plz help how to print python variable using os.system()

jitender001001
hi all
       i m new to python and i have a problem of printing python
variable using os.system() in bash

       !/usr/bin/env python

        var = "/home/anonymous"
        os.system("echo $var)

     it is not working..
   i want to print string  using os.system() ....plz help
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: plz help how to print python variable using os.system()

Lutz Horn-4
Hi,

On Wed, 16 Jan 2008 05:29:08 -0800 (PST), [hidden email] said:
>         var = "/home/anonymous"
>         os.system("echo $var)

os.system("echo %s" % var)

Lutz
--
GnuPG Key: 1024D/6EBDA359 1999-09-20
Key fingerprint = 438D 31FC 9300 CED0 1CDE  A19D CD0F 9CA2 6EBD A359
http://dev-random.dnsalias.net/0x6EBDA35.asc
http://pgp.cs.uu.nl/stats/6EBDA359.html

--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

Re: plz help how to print python variable using os.system()

jitender001001
In reply to this post by jitender001001
Reply | Threaded
Open this post in threaded view
|

Re: plz help how to print python variable using os.system()

Grant Edwards
In reply to this post by jitender001001
On 2008-01-16, Lutz Horn <[hidden email]> wrote:
> Hi,
>
> On Wed, 16 Jan 2008 05:29:08 -0800 (PST), [hidden email] said:
>>         var = "/home/anonymous"
>>         os.system("echo $var)
>
> os.system("echo %s" % var)

Though one wonders why one would do that instead of simply doing

print var

--
Grant Edwards                   grante             Yow! I'm ZIPPY the PINHEAD
                                  at               and I'm totally committed
                               visi.com            to the festive mode.
--
http://mail.python.org/mailman/listinfo/python-list
Reply | Threaded
Open this post in threaded view
|

RE: plz help how to print python variable using os.system()

Delaney, Timothy (Tim)
Grant Edwards wrote:

> On 2008-01-16, Lutz Horn <[hidden email]> wrote:
>> Hi,
>>
>> On Wed, 16 Jan 2008 05:29:08 -0800 (PST), [hidden email]
>> said:
>>>         var = "/home/anonymous"
>>>         os.system("echo $var)
>>
>> os.system("echo %s" % var)
>
> Though one wonders why one would do that instead of simply doing
>
> print var

Only reason I can think of is to learn how to use os.system before doing
something larger. But the OP should be using subprocess or popen in most
cases anyway ...

Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list