Re: OS specific command in Python

2006-06-21 Thread 3c273
"Avell Diroll" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 3c273 wrote: > > I was just trying to learn how to use .communicate() and all of the examples > > I see have [0] after .communicate(). What is the significance of the [0]? > > > From the Python Library Reference > (http:/

Re: OS specific command in Python

2006-06-21 Thread Avell Diroll
[EMAIL PROTECTED] wrote: (snip) > I have a linux box, from where I remotely execute all the commands. The > remote machine is windows machine. I installed an OpenSSH server for > windows to send the shutdown command. I setup the public keys in such a > way that I could login to SSH server without u

Re: OS specific command in Python

2006-06-21 Thread Avell Diroll
3c273 wrote: > I was just trying to learn how to use .communicate() and all of the examples > I see have [0] after .communicate(). What is the significance of the [0]? From the Python Library Reference (http://docs.python.org/lib/node239.html), you learn that the method communicate() from the

Re: OS specific command in Python

2006-06-21 Thread Avell Diroll
[EMAIL PROTECTED] wrote: > I have a question on getpass. Since I am a newbie you might find it a > little dumb. > > By using the getpass, are u trying to retrieve the username and > password of remote mahcine or local ? > the module getpass contains 2 functions, getuser() and getpass() : getuse

Re: OS specific command in Python

2006-06-21 Thread 3c273
"Avell Diroll" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > ##Python Script : > from subprocess import Popen > p1 = Popen(["dmesg"], stdout=PIPE) > p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) > output = p2.communicate()[0] I was just trying to learn how to use .commu

Re: OS specific command in Python

2006-06-21 Thread diffuser78
Hi Avell, I want to communicate using subprocess module but my task is a little different. May be you can guide me. I have a linux box, from where I remotely execute all the commands. The remote machine is windows machine. I installed an OpenSSH server for windows to send the shutdown command. I

Re: OS specific command in Python

2006-06-21 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: >> So basically, instead of typing in on the command line argument I want >> to have it in a python program and let it do the action. > > Try exec() and execfile() from the standard library (IIRC) Ths os.spawn...() functions are likely to b

Re: OS specific command in Python

2006-06-21 Thread diffuser78
I have a question on getpass. Since I am a newbie you might find it a little dumb. By using the getpass, are u trying to retrieve the username and password of remote mahcine or local ? Avell Diroll wrote: > [EMAIL PROTECTED] wrote: > > When you connect (via ssh or telnet) to a remote machine, y

Re: OS specific command in Python

2006-06-20 Thread Avell Diroll
[EMAIL PROTECTED] wrote: > When you connect (via ssh or telnet) to a remote machine, you need to > type (manually) > your username and your password. Programming that is never easy. > This is really eased by the module getpass (std library) : ### import getpass login = getpass.getuser() passwo

Re: OS specific command in Python

2006-06-20 Thread Avell Diroll
[EMAIL PROTECTED] wrote: > I tried the following and it seemed to work > > import os > os.system('') > > Any comments > This is an simple way to proceed if you don't need your python script to know what happens to the launched process ... When you need to : * send some input to the command

Re: OS specific command in Python

2006-06-20 Thread diffuser78
I tried the following and it seemed to work import os os.system('') Any comments -- http://mail.python.org/mailman/listinfo/python-list

Re: OS specific command in Python

2006-06-20 Thread diffuser78
When you connect (via ssh or telnet) to a remote machine, you need to > type (manually) > your username and your password. Programming that is never easy. I have setup the public keys to AUTO LOGIN so that it doesn't ask the password. -- http://mail.python.org/mailman/listinfo/python-list

Re: OS specific command in Python

2006-06-20 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] a écrit : > >> So basically, instead of typing in on the command line argument I want >> to have it in a python program and let it do the action. > >Try exec() and execfile() from the standard library (IIRC) > >> >> for

Re: OS specific command in Python

2006-06-19 Thread Avell Diroll
[EMAIL PROTECTED] wrote: > I want to write a python program and call OS specific commands in it. > So basically, instead of typing in on the command line argument I want > to have it in a python program and let it do the action. There are several ways to do so : * os.system() if you just want to l

Re: OS specific command in Python

2006-06-19 Thread stephanearnold
[EMAIL PROTECTED] a écrit : > So basically, instead of typing in on the command line argument I want > to have it in a python program and let it do the action. Try exec() and execfile() from the standard library (IIRC) > > for example. in my program I would want to call the ssh feature like > on

Re: OS specific command in Python

2006-06-19 Thread Robert Kern
[EMAIL PROTECTED] wrote: > I want to write a python program and call OS specific commands in it. > So basically, instead of typing in on the command line argument I want > to have it in a python program and let it do the action. > > for example. in my program I would want to call the ssh feature l