Results 1 to 6 of 6

Thread: Problem with subprocess in python

  1. #1
    Join Date
    Jul 2018
    Beans
    3

    Problem with subprocess in python

    Hi guys, having an issue running a subprocess in python.


    Code:
    if (__name__ == "__main__"):
        D = subprocess.Popen(args=sys.argv[1],
                                  stdout=subprocess.PIPE,
                                  stdin=subprocess.PIPE)
    Whenever I try to execute the script involving this code I get the following error:

    Code:
    Traceback (most recent call last):
    File "./attack.py", line 152, in <module>
    stdin=subprocess.PIPE)
    File "/usr/lib/python2.7/[/FONT]subprocess.py", line 394, in __init__
     errread, errwrite)
    File "/usr/lib/python2.7/[FONT=arial]subprocess.py", line 1047, in _execute_child
    raise child_exception
    OSError: [Errno 2] No such file or directory
    I then altered it to include shell = True, and then I get this issue:

    Code:
    /bin/sh: 1: 5.D: not found
    where 5.D is argv[1].

    I'm new to Ubuntu so any help would be appreciated
    Last edited by slickymaster; July 27th, 2018 at 09:17 AM. Reason: code tags

  2. #2
    Join Date
    Jun 2016
    Beans
    Hidden!

    Re: Problem with subprocess in python

    Quote Originally Posted by mfitzsimmons9 View Post
    Whenever I try to execute the script involving this code
    How are you running the script? Please post the full command line.

  3. #3
    Join Date
    Jul 2018
    Beans
    3

    Re: Problem with subprocess in python

    python ./attack.py 5.D 5.conf

    where 5.D and 5.conf are files which exist in the same directory as attack.py

  4. #4
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,937
    Distro
    Ubuntu

    Re: Problem with subprocess in python

    Thread moved to Programming Talk
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  5. #5
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Problem with subprocess in python

    What happens when you do:
    Code:
    5.D 5.conf
    Is 5.D executable? If not then
    Code:
    chmod +x 5.D
    Is it on your PATH? If not, either change your PATH or specify the path e.g.
    Code:
    python ./attack.py ./5.D 5.conf

  6. #6
    Join Date
    Jul 2018
    Beans
    3

    Re: Problem with subprocess in python

    Thanks for the help mate

    python ./attack.py ./5.D 5.conf

    Solved the problem. I didn't think about the .D file being an executable.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •