By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

open a shell prompt froma python program

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.