0

I am executing a shell script through a pipe in Python as follows:

def(request,self):
    args_str1 = "flexiserver/build/svnenv.sh -j 'svntasktag.pl ss_fvnteste'"
    args1 = shlex.split(args_str1)
    pi = subprocess.Popen(args1, stdout=subprocess.PIPE)

    print("***** Before out err *****")
    out, err = pi.communicate()
    print(" OUT is %s " , out)

    context = {'out':out, 'err':err}
    req_context = RequestContext(request)
    return render_to_response(
        'pai_app/create_tag.html', context, context_instance=req_context)

This script is waiting for user input like 'i', 'm', 'c' like arguments. Until the user gives any input it is not printing and not showing in webui.

My question is, is there any possibility to run such Perl or shell scripts in webui itself? Or is there any other resolution for the above problem? Could anyone help me in this as i am struck.

sshine
  • 15,635
  • 1
  • 41
  • 66
SinghB
  • 29
  • 1
  • 5

1 Answers1

0

While your Python code is opening a pipe to a shell script that takes as argument something that looks like it's a Perl script, this question is really related to pipes in Python.

This script is waiting for user input like 'i', 'm', 'c' like arguments.

You can send an 'i' to the process using pi.communicate('i').

sshine
  • 15,635
  • 1
  • 41
  • 66
  • I added as pi.communicate('i') but no luck. still it is awaiting for input pi = subprocess.Popen(args1, stdout=subprocess.PIPE) out, err = pi.communicate('i') print(" OUT is %s " , out) context = {'out':out, 'err':err} return render_to_response('pai_app/create_tag.html', {'out':out, 'err':err}, context_instance=RequestContext(request)) – SinghB Apr 03 '18 at 12:18
  • You understand, then, that there's something you're not saying. – sshine Apr 03 '18 at 12:41
  • is it possible to run the complete script including user input in the html form I mean like as we normally run in linux console ? – SinghB Apr 04 '18 at 06:21