[Tutor] Offtopic: Re: killing bash, sshd... dangerous?

2007-10-28 Thread Eric Brunson
John wrote: > No, mostly just playing around with scripting and I have a problem > sometimes with cygwin where logging out from bash session Hi John, This is a known bug. The fix is to install a real operating system. For more info, please see one of the following: http://distrowatch.co

Re: [Tutor] killing bash, sshd... dangerous?

2007-10-28 Thread John
No, mostly just playing around with scripting and I have a problem sometimes with cygwin where logging out from bash session, the xterm hangs, so this seems to fix it... but it's not really the best solution... needs some mods, I'm sure. On 10/28/07, Tom Tucker <[EMAIL PROTECTED]> wrote: > >

Re: [Tutor] os.sys

2007-10-28 Thread Alan Gauld
"Lawrence Shafer" <[EMAIL PROTECTED]> wrote > Why doesn't this fill otp with the output of ls?? (I know python has > it's own file tools, I'm just playing around ;) > > otp=os.system(cmd) Because os.system returnsd the exit status of the command. zero means the command executed OK anything else

Re: [Tutor] os.sys

2007-10-28 Thread Andrew Nelsen
On 10/28/07, Lawrence Shafer <[EMAIL PROTECTED]> wrote: > > Why doesn't this fill otp with the output of ls?? (I know python has > it's own file tools, I'm just playing around ;) > > import os > cmd="""ls""" > otp=os.system(cmd) > print otp > ___ > Tutor

Re: [Tutor] os.sys

2007-10-28 Thread James
Try using the commands, instead. import commands cmd = 'ls' opt = commands.getoutput( cmd ) print opt More information found here: http://docs.python.org/lib/module-commands.html :) .james On Oct 28, 2007, at 12:44 PM, Lawrence Shafer wrote: > Why doesn't this fill otp with the output of ls

[Tutor] os.sys

2007-10-28 Thread Lawrence Shafer
Why doesn't this fill otp with the output of ls?? (I know python has it's own file tools, I'm just playing around ;) import os cmd="""ls""" otp=os.system(cmd) print otp ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tuto

Re: [Tutor] killing bash, sshd... dangerous?

2007-10-28 Thread Tom Tucker
Instead of reading in an outputfile (.ps), try reading from command output. The correct terminology escapes me (for file in os.popen(cmd).readlines():). Are you looking for a auto logout method? For example if no activity after X minutes kill the shell. Bash and a few other shells have this func

Re: [Tutor] 'source' in python or preloading variables

2007-10-28 Thread Alan Gauld
"John" <[EMAIL PROTECTED]> wrote > But won't if fail since the variabls in the file are not quoted? No the quoting is only necessary if you use eval/exec. The quotes prevent the interpreter from treating them as variable names. If you read the values from the file they are already strings,

[Tutor] killing bash, sshd... dangerous?

2007-10-28 Thread John
Hello, I've written a little script with the intention of killing all of my bash, sshd sessions... is this dangerous? How could I make it work so that it didn't kill the session it was run from (as it is I suppose I have to run it with nohup): #!/usr/bin/env python import os cmd="ps -u myuser |

Re: [Tutor] More type() puzzlement

2007-10-28 Thread Dick Moores
At 01:53 AM 10/28/2007, you wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > > So you're saying that it's to be expected that the analogy, "int is > > to long as int is to float" will hold. But why should it be expected > > to hold? float and long are completely different animals, no? > >No, th

Re: [Tutor] 'source' in python or preloading variables

2007-10-28 Thread John
But won't if fail since the variabls in the file are not quoted? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] system call

2007-10-28 Thread John
Here is my actual code (a section of a long script): if os.path.isdir(ad) and aRun.split('_')[0]==STN_id[i] and in (aRun.split ('_')[1]): make_pages=os.path.join(BASEDIR,STN_id[i],SUBDIR[1],'make_pages') sedstr1="""cat %s | sed -e 's/ASYSmin=[0-9][0-9]*/ASYSmin=%s/g' > jnk""" % (make_webpage

Re: [Tutor] how to run function only for a pre-defined time

2007-10-28 Thread Vinu Vikram
Hi alan Thanks. But if I write a code like the followiing, how I can stop the thread #!/usr/bin/env python import threading import time, os class Infi(threading.Thread): def __init__(self, a): self.a = a threading.Thread.__init__(self) def run(self): i = 1 while i==1: pri

Re: [Tutor] More type() puzzlement

2007-10-28 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote > So you're saying that it's to be expected that the analogy, "int is > to long as int is to float" will hold. But why should it be expected > to hold? float and long are completely different animals, no? No, they are all types of numbers. The general rule

Re: [Tutor] system call

2007-10-28 Thread Alan Gauld
"Eric Walker" <[EMAIL PROTECTED]> wrote > The problem is that I have another tool that has an initialization > period when you start it up. I want to see how long it takes Have you considered just using the Unix time command? > So, to time the entire init process, I want to use python. As a