open a shell prompt froma python program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gaurav kashyap

    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
  • Lars Stavholm

    #2
    Re: open a shell prompt froma python program

    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")

    Comment

    • gaurav kashyap

      #3
      Re: open a shell prompt froma python program

      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

      Comment

      • Diez B. Roggisch

        #4
        Re: open a shell prompt froma python program

        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

        Comment

        • gaurav kashyap

          #5
          Re: open a shell prompt froma python program

          HI,
          I am getting the following error:

          konsole: cannot connect to X server

          do i need to install the related files.

          Comment

          • bernhard.voigt@gmail.com

            #6
            Re: open a shell prompt froma python program

            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

            Comment

            • Derek Martin

              #7
              Re: open a shell prompt froma python program

              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

              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-----

              Comment

              • Grant Edwards

                #8
                Re: open a shell prompt froma python program

                On 2008-10-30, Derek Martin <code@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"!!

                Comment

                • Derek Martin

                  #9
                  Re: open a shell prompt froma python program

                  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

                  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-----

                  Comment

                  • Lawrence D'Oliveiro

                    #10
                    Re: open a shell prompt froma python program

                    In message
                    <8aef8ae0-5b65-4e4b-a65a-f7b0c0676a31@c2 g2000pra.google groups.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?

                    Comment

                    Working...