open a shell prompt froma python program

G

gaurav kashyap

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
 
L

Lars Stavholm

gaurav said:
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")
 
G

gaurav kashyap

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
 
D

Diez B. Roggisch

gaurav said:
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
 
G

gaurav kashyap

HI,
I am getting the following error:

konsole: cannot connect to X server

do i need to install the related files.
 
B

bernhard.voigt

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
 
D

Derek Martin

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+XdjdlQoHP510RAibkAJsHwF1yPBZzBH0yLtJJHjiZaQV0lQCdGMwm
o/DdLJ2/V8du5OC9Y3z6jdg=
=qYUJ
-----END PGP SIGNATURE-----
 
D

Derek Martin

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)

iD8DBQFJCjl0djdlQoHP510RAgVPAJ9lk6Xg4WA8FiWYFk9xdl9Edb+U0gCgkkiL
owSZZPOKeMJMv1WAlWyWwQM=
=20X0
-----END PGP SIGNATURE-----
 
L

Lawrence D'Oliveiro

In message
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top