473,569 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7991
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+Xdjd lQoHP510RAibkAJ sHwF1yPBZzBH0yL tJJHjiZaQV0lQCd GMwm
o/DdLJ2/V8du5OC9Y3z6jdg =
=qYUJ
-----END PGP SIGNATURE-----

Oct 30 '08 #7
On 2008-10-30, Derek Martin <co**@pizzashac k.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)

iD8DBQFJCjl0djd lQoHP510RAgVPAJ 9lk6Xg4WA8FiWYF k9xdl9Edb+U0gCg kkiL
owSZZPOKeMJMv1W AlWyWwQM=
=20X0
-----END PGP SIGNATURE-----

Oct 30 '08 #9
In message
<8a************ *************** *******@c2g2000 pra.googlegroup s.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
5300
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 these files, I wish to do the same using another python code instead of running each of these files one by one, which would be cumbersome giving the...
4
1820
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 do stuff with the contents of that list. I started with a BASH script actually, until I realized I really needed
4
3041
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 dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log...
10
2258
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
2181
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 simply drops an existing database called 'mytempdb'. the code looks like below; link = subprocess.Popen(command, stdin = subprocess.PIPE,...
14
2644
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 run from within the editor or is that not how development is done? I ask because I was using Visual Studio with C# and, if you're familiar, you just...
3
2137
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 file like above in a new shell prompt
3
9047
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 windows read the URL currently displayed in each web browser and if the URL matches a particular regular expression it needs to get/set form fields...
0
1524
by: bruce | last post by:
hi mike.... you might look at/into selenium, or firewatir.... check the spellings! -peace -----Original Message-----
0
7701
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
7615
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
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7979
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
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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
3653
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...
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.