473,698 Members | 2,528 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 7995
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
5314
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 argv of each file every single time. This can be easily done using a shell script but I just...
4
1822
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
3047
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 the results to a text file called update.log. When I run the program in a bash shell with the...
10
2270
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
2187
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, stdout =
14
2653
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 hit run and it works. On Python do I use the editor for editing only and then run the program from...
3
2142
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
9053
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 displayed in the web browser. Basically I need something like Windows COM and Internet Explorer...
0
1529
by: bruce | last post by:
hi mike.... you might look at/into selenium, or firewatir.... check the spellings! -peace -----Original Message-----
0
8678
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5861
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2
2333
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.