open a shell prompt froma python program

Discussion in 'Python' started by gaurav kashyap, Oct 30, 2008.

  1. 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
     
    gaurav kashyap, Oct 30, 2008
    #1
    1. Advertising

  2. 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")
     
    Lars Stavholm, Oct 30, 2008
    #2
    1. Advertising

  3. On Oct 30, 2:59 pm, Lars Stavholm <> wrote:
    > 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
     
    gaurav kashyap, Oct 30, 2008
    #3
  4. gaurav kashyap wrote:

    > On Oct 30, 2:59 pm, Lars Stavholm <> wrote:
    >> 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
     
    Diez B. Roggisch, Oct 30, 2008
    #4
  5. HI,
    I am getting the following error:

    konsole: cannot connect to X server

    do i need to install the related files.
     
    gaurav kashyap, Oct 30, 2008
    #5
  6. gaurav kashyap

    Guest

    On Oct 30, 11:53 am, gaurav kashyap <> wrote:
    > 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, 2008
    #6
  7. gaurav kashyap

    Derek Martin Guest

    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+XdjdlQoHP510RAibkAJsHwF1yPBZzBH0yLtJJHjiZaQV0lQCdGMwm
    o/DdLJ2/V8du5OC9Y3z6jdg=
    =qYUJ
    -----END PGP SIGNATURE-----
     
    Derek Martin, Oct 30, 2008
    #7
  8. gaurav kashyap

    Derek Martin Guest

    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)

    iD8DBQFJCjl0djdlQoHP510RAgVPAJ9lk6Xg4WA8FiWYFk9xdl9Edb+U0gCgkkiL
    owSZZPOKeMJMv1WAlWyWwQM=
    =20X0
    -----END PGP SIGNATURE-----
     
    Derek Martin, Oct 30, 2008
    #8
  9. In message
    <>, 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?
     
    Lawrence D'Oliveiro, Nov 1, 2008
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gregory Bloom
    Replies:
    4
    Views:
    355
    Steve Holden
    Apr 28, 2007
  2. gaurav kashyap
    Replies:
    2
    Views:
    622
    gaurav kashyap
    Oct 30, 2008
  3. gaurav kashyap
    Replies:
    3
    Views:
    688
    gaurav kashyap
    Oct 31, 2008
  4. Joel Goldstick
    Replies:
    1
    Views:
    92
    alex23
    Jul 2, 2013
  5. Dave Angel
    Replies:
    2
    Views:
    104
    Dave Angel
    Jul 2, 2013
Loading...

Share This Page