Jonathan Jonathan - 2 years ago 53
Perl Question

How to invoke perl script that need args from python

i'm new to python...
i'm writing my script in python and i want to invoke perl script from it

this is the line i want to call

perl arg1 arg2

while arg1 is the input from the python script and arg2 is new file that
i'm creating

so far i have this

def main(argv):
file = open("test.hex","w")
input = argv[0];["perl", "", input]);

this run and do nothing

and when i'm changing the["perl", "", input]);

to["perl", "", input ,file]);

it doesnt compile...

I'm sure its a very novice question....

Answer Source

As you've described it, the program you're running expects its second argument to be the name of a file, so that's what you need to give it. In your current code, you're giving it a Python file object, which is not the same as the string name of a file.["perl", "", input, "test.hex"]);

There is no need to create the file object prior to running that code, either. The other program will surely create it for you, and might even balk if it finds that the file already exists.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download