473,549 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Launching scripts in Ubuntu ?

hello,

I'm not familiar with Linux / Ubuntu,
still trying to get my application working under these operating systems.

I've a script "file_support.p y",
now when I'm in Ubuntu, open a command window and go to the directory
where that file is,
I can launch the script with :
"python file_support.py "
and it works great

Now when I want to run the script from another script, let's call it "
test.py"
where this is the contents of test.py:

import subprocess
subprocess.Pope n ( [ 'python', 'file_support.p y', ] )

The script "file_suppo rt" is executed correctly,
but the python interpreter is not closed,
I've to close it manual by pressing ENTER.

What should I change ?

thanks,
Stef Mientki
Oct 14 '08 #1
5 1764
Stef Mientki wrote:
hello,

I'm not familiar with Linux / Ubuntu,
still trying to get my application working under these operating systems.

I've a script "file_support.p y",
now when I'm in Ubuntu, open a command window and go to the directory
where that file is,
I can launch the script with :
"python file_support.py "
and it works great

Now when I want to run the script from another script, let's call it "
test.py"
where this is the contents of test.py:

import subprocess
subprocess.Pope n ( [ 'python', 'file_support.p y', ] )

The script "file_suppo rt" is executed correctly,
but the python interpreter is not closed,
I've to close it manual by pressing ENTER.
What do you mean "it's not closed"? Which window is taking the enter, and
how do you run test.py?

Diez
Oct 14 '08 #2
Diez B. Roggisch wrote:
Stef Mientki wrote:

>hello,

I'm not familiar with Linux / Ubuntu,
still trying to get my application working under these operating systems.

I've a script "file_support.p y",
now when I'm in Ubuntu, open a command window and go to the directory
where that file is,
I can launch the script with :
"python file_support.py "
and it works great

Now when I want to run the script from another script, let's call it "
test.py"
where this is the contents of test.py:

import subprocess
subprocess.Pop en ( [ 'python', 'file_support.p y', ] )

The script "file_suppo rt" is executed correctly,
but the python interpreter is not closed,
I've to close it manual by pressing ENTER.

What do you mean "it's not closed"?
well the command prompt (if it is called that way in Linus) is not returned.

When I run file_support, the command window looks like this
>>>python file_support.py
...... all kinds of output
>>>
When I run test.py (which calls fie_support) , I get this
>>>python test.py
..... all kinds of output (the same as before)

Now I've to explicitly press an enter to get the command prompt back.
This might not sound important,
but the problem is somewhat more complex,
all these scripts are ran from another program,
and although everything works fine under windows,
the program hangs on Ubuntu.
So I guess that this is the (first) problem to solve.

thanks,
Stef


Which window is taking the enter, and
how do you run test.py?

Diez
--
http://mail.python.org/mailman/listinfo/python-list
Oct 14 '08 #3
>What do you mean "it's not closed"?
well the command prompt (if it is called that way in Linus) is not
returned.

When I run file_support, the command window looks like this
>>>python file_support.py
..... all kinds of output
>>>

When I run test.py (which calls fie_support) , I get this
>>>python test.py
.... all kinds of output (the same as before)

Now I've to explicitly press an enter to get the command prompt back.
This might not sound important,
but the problem is somewhat more complex,
all these scripts are ran from another program,
and although everything works fine under windows,
the program hangs on Ubuntu.
So I guess that this is the (first) problem to solve.
This looks odd. I've never seen a *shell* display ">>>" as prompt. So it
looks as if you mix stuff between the shell (bash, tcsh, whatever) and
python in the above. Are you *inside* the python interpreter already when
typing "python test.py"?

And if *not*, does typing e.g. "ls <return>" work for you, right after the
test.py is run? Then there is no "getting back of the prompt", it's just
that a last newline is .. well, not even missing, just not printed.
Consider this (I use $ for the shellpromt):

$ python -c "import sys;sys.stdout. write('hello')"
hello$

Additonally, you might want to check out the Popen-object-reference for the
wait-call, but actually that shouldn't change anything with regards to
pressing enter or not.

Diez
Oct 14 '08 #4
Diez B. Roggisch wrote:
>>What do you mean "it's not closed"?
well the command prompt (if it is called that way in Linus) is not
returned.

When I run file_support, the command window looks like this
> >>>python file_support.py
..... all kinds of output
> >>>

When I run test.py (which calls fie_support) , I get this
> >>>python test.py
.... all kinds of output (the same as before)

Now I've to explicitly press an enter to get the command prompt back.
This might not sound important,
but the problem is somewhat more complex,
all these scripts are ran from another program,
and although everything works fine under windows,
the program hangs on Ubuntu.
So I guess that this is the (first) problem to solve.

This looks odd. I've never seen a *shell* display ">>>" as prompt.
">>>" stands for:
stef@stef-desktop:/media/disk/Data_Python_25/support$
So it
looks as if you mix stuff between the shell (bash, tcsh, whatever) and
python in the above. Are you *inside* the python interpreter already when
typing "python test.py"?
So no
And if *not*, does typing e.g. "ls <return>" work for you, right after the
test.py is run?
yes it does
Then there is no "getting back of the prompt", it's just
that a last newline is .. well, not even missing, just not printed.
Consider this (I use $ for the shellpromt):

$ python -c "import sys;sys.stdout. write('hello')"
hello$

Additonally, you might want to check out the Popen-object-reference for the
wait-call, but actually that shouldn't change anything with regards to
pressing enter or not.
ok It seems to be solved now,
In creating a small example to emphasize the problem,
I found the difference between Win and Linux:
In windows "shell=True " and in Linux "shell=Fals e"
PID = subprocess.Pope n( arguments,
cwd = cwd ,
stdout = subprocess.PIPE ,
stderr = subprocess.PIPE ,
shell = ( os.name == 'nt') )
so the above statement seems (at least for the moment) solve all the
problems.

thank you all,
Stef

Oct 14 '08 #5
En Tue, 14 Oct 2008 10:46:34 -0300, Stef Mientki <st**********@g mail.com>
escribió:
>>well the command prompt (if it is called that way in Linus) is not
returned.

When I run file_support, the command window looks like this
>>>python file_support.py
..... all kinds of output
>>>

When I run test.py (which calls fie_support) , I get this
>>>python test.py
.... all kinds of output (the same as before)

Now I've to explicitly press an enter to get the command prompt back.
ok It seems to be solved now,
In creating a small example to emphasize the problem,
I found the difference between Win and Linux:
In windows "shell=True " and in Linux "shell=Fals e"
PID = subprocess.Pope n( arguments,
cwd = cwd ,
stdout = subprocess.PIPE ,
stderr = subprocess.PIPE ,
shell = ( os.name == 'nt') )
so the above statement seems (at least for the moment) solve all the
problems.
I'd say there is no problem. It just *appears* to be one. The first
program finishes, and the shell displays its prompt, while the child is
still outputting things. I bet you can see the stef@stef-desktop...$
somewhere in the output.

It's like executing:
$ ls&
the shell prompt is shown as soon as the ls (background) process starts,
but gets lost in the output.
Diez B. Roggisch wrote:
>Additonally, you might want to check out the Popen-object-reference for
the
wait-call, but actually that shouldn't change anything with regards to
pressing enter or not.
Calling wait in the parent script would prevent it to finish before the
child, avoiding the issue.

--
Gabriel Genellina

Oct 14 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2474
by: Martin Maney | last post by:
Apologies if this isn't news here - I've been too busy this last week or so for even skimming the traffic here, in part because I've been messing around with Ubuntu's preview release on a spare machine... and, of course, spending time on their very busy mailing list. :-) I didn't find any mention of Ubuntu in a quick scan of recent messages,...
6
2633
by: Ernesto | last post by:
Does anyone know how to start Python program(s) from a Linux shell script? Is it just $python myscript.py ?? Thanks,
2
2641
by: SPE - Stani's Python Editor | last post by:
Hi, I'm playing around with the latest (soon to be released) SPE on Ubuntu. This probably will increase the quality of SPE on Ubuntu and Linux/GTK in general. I already made some patches, but I would like to get in contact with SPE users on Ubuntu. The version of SPE which is now available on Ubuntu now is quite deprecated. I adapted SPE...
2
1270
by: Byte | last post by:
Decided to try the eric3 IDE, but I cant figure out how to start it! When I extract the file, all I can see is a ton of files and Python scripts. What script will run the program? Where is it? Please help! -- /usr/bin/byte
2
2942
by: Pradnyesh Sawant | last post by:
Hello, I have a newly installed ubuntu 6.06 system. I am trying to install pyqt4 on it, but without success. The contents of the /etc/apt/sources.list file are: ******************************************************************************** deb http://in.archive.ubuntu.com/ubuntu/ dapper main restricted universe deb...
8
2269
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I would like to find out how I can launch an independent Python program from existing one in a cross-platform way. The result I am after is that a new terminal window should open (for io independent of the original script). The following seems to work correctly under Ubuntu and Windows ... but I haven't been able to find a way to make it...
0
2087
by: ratcateme | last post by:
I am using apache 2.2.4 and perl 5.8.8 on Ubuntu 7.10 I am creating a website mainly in PHP but i have a few perl scripts i want to run. I am running a simple script but get this error a Internal Server Error 500 the apache error.log file says: (2)No such file or directory: exec of '/var/www/cgi-bin/test.cgi' failed Premature end of...
5
1400
jimpy
by: jimpy | last post by:
Greetings, Using Ubuntu 7.10 and Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) on linux2 I am presently going through the "A Byte Of Python" tutorial. When I copy the little .py scripts and save them, I find they must be in the /usr/bin directory. But I cannot directly save them to that location. I have to save them to my Documents...
11
2925
by: Ix | last post by:
It seems not remember how to compile with gcc a C program in linux (ubuntu) how i have to compile this programme? It seems gcc doesn't find stdio.h.. why is all antiintuitive? Thank you and Good Morning ---------------------------------------------------
0
7554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7992
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7511
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7840
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5119
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1973
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.