简体   繁体   English

将Python变量作为参数传递给Perl脚本

[英]Passing Python variables as an arguments to a perl script

I have a Django project where one of the Python functions uses a Perl script, and I am passing Python variables as arguments. 我有一个Django项目,其中Python函数之一使用Perl脚本,并且我将Python变量作为参数传递。

But instead of using the values of the Python variables it is passing the variable names. 但是,不是使用Python变量的值,而是传递变量名。

How can I pass these variables generically to a Perl script? 如何将这些变量通用地传递给Perl脚本?

log output is as follows:
('Isource username is %s ', u'sudhb')
('Isource password is %s ', u'123456')
(' Command is %s ', ['flexiserver/build/svnenv.sh', '-j', 'svntasktag.pl -u i_uname -a i_passw ss_fvnteste'])

Python code Python代码

i_uname = request.POST.get('uname')
i_passw = request.POST.get('ispsw')

args_str1 = "flexiserver/build/svnenv.sh -j 'svntasktag.pl -u " + i_uname + " -a " + i_passw + " -c \"" + i_desc + "\" ss_fvnteste'"
args1     = shlex.split(args_str2)
pi = subprocess.Popen(args1, stdout=subprocess.PIPE)
stdout = pi.communicate()

This issue has been resolved by using replace in python. 通过在python中使用replace已解决了此问题。 I replaced back slash as follows 我如下替换了反斜杠

args_str1 = "flexiserver/build/svnenv.sh -j 'svntasktag_pdash.pl -u " + i_uname + " -a " + i_passw + " -c \"" + i_desc + "\" ss_fvnteste'"

            args2 = str(args_str1).replace("\\","")

This worked for me 这对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM