Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am using the subprocess() which has subprocess.run() as shown below:

  p = subprocess.run([

        '/home/ubuntu/my_script.sh',

        'my_arg_1',

        'my_arg_2'

    ])

When I run the above command after a few seconds it just gives me a hand full of files as if it didn't even run. It doesn't throw me any error.

I have run the below code in the shell

$ /home/ubuntu/my_script.sh my_arg_1 my_arg_2

The above code runs a few more seconds more compared to the previous code. I have cross-checked many times if there is any mistake, between the Linux code and the concatenation of argument code. 

Would there be a permission issue? Can anyone help me?

I am sharing the actual command as shown below:

/home/ubuntu/DataScience/alphapose_dress.sh /home/ubuntu/dresses/whole-dresses/VahT2ei1no.jpg /home/ubuntu/dresses/alphapose_results

So this, not the path issue either

The second code:

cmd = [

    config.alphapose_script,

    img_path,

    config.alphapose_outdir

with Popen(cmd, stdout=PIPE, bufsize=1, universal_newlines=True) as p:

    for line in p.stdout:

        print(line, end='')

It prints nothing. Can somebody help me?

1 Answer

0 votes
by (36.8k points)

You can try which will help you, I am giving the code below :

from subprocess import run,PIPE 

p = run([ '/home/ubuntu/my_script.sh', 'my_arg_1', 'my_arg_2' ], stdout=PIPE, stderr=PIPE)

 print(p.stderr)

This will print you an error.

If you want to know more about the Data Science then do check out the following Data Science link which will help you in understanding Data Science from scratch

Browse Categories

...