473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

open a shell prompt froma python program

Dear all,

Can u tell me a python program that when executed in a shell
prompt,opens another shell prompt.

Simply i want to open a shell prompt from a python program.

Thanks
Oct 30 '08 #1
9 7973
gaurav kashyap wrote:
Dear all,

Can u tell me a python program that when executed in a shell
prompt,opens another shell prompt.

Simply i want to open a shell prompt from a python program.
I think you're looking for:

import os
os.system("/bin/sh")

Oct 30 '08 #2
On Oct 30, 2:59*pm, Lars Stavholm <st...@telcotec.sewrote:
gaurav kashyap wrote:
Dear all,
Can u tell me a python program that when executed in a shell
prompt,opens another shell prompt.
Simply i want to open a shell prompt from a python program.

I think you're looking for:

import os
os.system("/bin/sh")


Dear,

Its not opening a new window,
I want to do that only from already opened shell prompt window
Oct 30 '08 #3
gaurav kashyap wrote:
On Oct 30, 2:59Â*pm, Lars Stavholm <st...@telcotec.sewrote:
>gaurav kashyap wrote:
Dear all,
Can u tell me a python program that when executed in a shell
prompt,opens another shell prompt.
Simply i want to open a shell prompt from a python program.

I think you're looking for:

import os
os.system("/bin/sh")

Dear,

Its not opening a new window,
I want to do that only from already opened shell prompt window
Then you need to open a terminal, like xterm or konsole. Use
os.system("/usr/bin/konsole")

Diez
Oct 30 '08 #4
HI,
I am getting the following error:

konsole: cannot connect to X server

do i need to install the related files.
Oct 30 '08 #5
On Oct 30, 11:53*am, gaurav kashyap <gauravkec2...@gmail.comwrote:
HI,
I am getting the following error:

konsole: cannot connect to X server

do i need to install the related files.
Do you have an x-server running? I assume so, because you have a
terminal window opened.

If you became root using su, you need to allow connections to x-
server, which is started by the regular user. you can do this for
local access using
$ xhost local:

Best wishes! Bernhard
Oct 30 '08 #6
On Thu, Oct 30, 2008 at 03:53:52AM -0700, gaurav kashyap wrote:
HI,
I am getting the following error:

konsole: cannot connect to X server

do i need to install the related files.
Maybe, but given that error message, probably not.

You would do yourself a great favor by providing a lot more detail
about what you are trying to do... On a Unix/Linux system, unlike
Windows, there is no one single "shell prompt window" -- there are
lots of them. They all need the X Window System (a suite of software
which provides a GUI interface to Unix systems -- it's not "built in"
like it is in Windows). X works as a client-server model, and you
need to make sure X authentication is handled properly. Depending on
what you are doing, this can be either very easy, or very complicated.

--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFJCc+XdjdlQoHP510RAibkAJsHwF1yPBZzBH0yLtJJHj iZaQV0lQCdGMwm
o/DdLJ2/V8du5OC9Y3z6jdg=
=qYUJ
-----END PGP SIGNATURE-----

Oct 30 '08 #7
On 2008-10-30, Derek Martin <co**@pizzashack.orgwrote:
On Thu, Oct 30, 2008 at 03:53:52AM -0700, gaurav kashyap wrote:
>HI,
I am getting the following error:

konsole: cannot connect to X server

do i need to install the related files.

Maybe, but given that error message, probably not.

You would do yourself a great favor by providing a lot more detail
about what you are trying to do... On a Unix/Linux system, unlike
Windows, there is no one single "shell prompt window" -- there are
lots of them.
There are both lots of "shell prompt windows" (which, I assume
means terminal emulators), and lots of shells and other
programs you can run in such a window.
They all need the X Window System (a suite of software which
provides a GUI interface to Unix systems -- it's not "built
in" like it is in Windows). X works as a client-server model,
and you need to make sure X authentication is handled
properly. Depending on what you are doing, this can be either
very easy, or very complicated.
--
Grant Edwards grante Yow! This PORCUPINE knows
at his ZIPCODE ... And he has
visi.com "VISA"!!
Oct 30 '08 #8
On Thu, Oct 30, 2008 at 02:47:48AM -0700, gaurav kashyap wrote:
Simply i want to open a shell prompt from a python program.
If this is literally true, then you just need to figure out what
command will open a terminal window from the shell prompt. Once you
figure that out, it's as simple as:

cmd = "whatever your shell command is"
os.system(cmd)

--
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFJCjl0djdlQoHP510RAgVPAJ9lk6Xg4WA8FiWYFk9xdl 9Edb+U0gCgkkiL
owSZZPOKeMJMv1WAlWyWwQM=
=20X0
-----END PGP SIGNATURE-----

Oct 30 '08 #9
In message
<8a**********************************@c2g2000pra.g ooglegroups.com>, gaurav
kashyap wrote:
konsole: cannot connect to X server
Could be it's not being passed the right DISPLAY setting. Is this under the
same username, so it's automatically using the right xauth settings?
Nov 1 '08 #10

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

Similar topics

5
by: Shalen chhabra | last post by:
Hey, Can anyone give me a snippet for running a python program over all the files in the directory. For ex: I have ten files in a directory and I want to run a python program against all of...
4
by: Sandman | last post by:
Hi, I'm a newbie, so please be gentle :-) How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and...
4
by: vagrantbrad | last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the...
10
by: A.M | last post by:
Hi, I am having difficulty with shell scripting in Python. I use the following command to run a DOS command and put the return value in a Python variable:
7
by: damacy | last post by:
hi, there. i have this question which might sound quite stupid to some people, but here we go anyway. i have written a python program which interacts with a postgresql database. what it does is...
14
by: jmDesktop | last post by:
Hi, I'm trying to learn Python. I using Aquamac an emac implementation with mac os x. I have a program. If I go to the command prompt and type pythong myprog.py, it works. Can the program be...
3
by: gaurav kashyap | last post by:
Dear all. On windows platform python 2.4,i can use os.startfile("filename") to execute a file on a new command prompt but on unix platform and python 2.3 what is the alternate for executing a...
3
by: Scott | last post by:
I have a requirement to control a firefox web browser from an external python program. The python program running under linux from a command shell needs to first find all open firefox web browser...
0
by: bruce | last post by:
hi mike.... you might look at/into selenium, or firewatir.... check the spellings! -peace -----Original Message-----
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.