My Django application successfully executes functions belonging to
user amr. I want to execute an external command line application from
views.py

def exec_external_cmd(cmd_line):
    retcode = None
    try:
        process = Popen(cmd_line, bufsize=2048, executable="/bin/
bash", shell=True, stdout=None, stderr=None)

        while retcode == None:
            retcode = process.poll()

        if retcode < 0:
            print >>sys.stderr, "Child was terminated by signal", -
retcode
        elif retcode > 0:
            print >>sys.stderr, "Child returned", retcode

    except OSError, e:
        print >>sys.stderr, "Execution failed:", e

    return retcode

def proc_inv_file(request):
    info_dict = {}

    errors = []
    inventory_file = ''
    inventory_file_path = ''

    if request.method == 'GET':
        if not request.GET.get('inventory_file', ''):
            errors.append('Please enter a valid inventory file name.')
        else:
            if not request.GET.get('inventory_file_path', ''):
                errors.append('Please enter a valid inventory file
name path.')
            else:
                inventory_file = request.GET.get('inventory_file', '')
                inventory_file_path =
request.GET.get('inventory_file_path', '')

                cmd_line = "/home/amr/bin/invXfer.py " + " " +
inventory_file + " " + inventory_file_path
                rc = exec_external_cmd(cmd_line)

If I run invXfer.py logged in as amr, it runs fine. From Django I get
an error, 1.

How can I launch an external program as the logged in user from
Django?

Thanks.
cmn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to