[IPython-user] using jobctrl

Stefan van der Walt stefan at sun.ac.za
Sat Dec 16 12:41:42 CST 2006


Hi,

I am trying to get the 'jobctrl' extension running.  When I run '&ls',
it gives:

In [4]: &ls
---------------------------------------------------------------------------
exceptions.OSError                                   Traceback (most recent call last)

/home/stefan/<ipython console> 

/home/stefan/lib/python2.4/site-packages/IPython/Extensions/jobctrl.py in startjob(job)
     39                   
     40 def startjob(job):
---> 41     p = IpyPopen(job, stdout=PIPE, shell = False)
     42     p.line = job
     43     return p

/home/stefan/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    541                             p2cread, p2cwrite,
    542                             c2pread, c2pwrite,
--> 543                             errread, errwrite)
    544
    545         if p2cwrite:

/home/stefan/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
    973                 os.waitpid(self.pid, 0)
    974                 child_exception = pickle.loads(data)
--> 975                 raise child_exception
    976 
    977 

OSError: [Errno 2] No such file or directory


The command,

In [14]: p  = jobctrl.startjob("ls -F "),

which is generated on line 50 of jobctrl.py, fails.  This seems to be
because subprocess.Popen expects a list of arguments, instead of a
string, i.e.

['ls','-F']

Seems like simply changing line 41 in jobctrl.py to read

p = IpyPopen(job.split(), ...)

fixes the problem.

Cheers
Stéfan
-------------- next part --------------
Index: jobctrl.py
===================================================================
--- jobctrl.py	(revision 2004)
+++ jobctrl.py	(working copy)
@@ -38,7 +38,7 @@
         os.system('taskkill /PID %d' % self.pid)

                   

 def startjob(job):

-    p = IpyPopen(job, stdout=PIPE, shell = False)

+    p = IpyPopen(job.split(), stdout=PIPE, shell=False)

     p.line = job

     return p

 



More information about the IPython-user mailing list