LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2007, 03:14 PM   #1
cdd
LQ Newbie
 
Registered: May 2007
Posts: 3

Rep: Reputation: 0
perl script call python -linux


Hi,
I have a perl script that is running in windows environment. This is calling python BodyTextExtractor.
My problem is: I have to move the script to run on linux and I have to change the following part of the script and I don't know how. Please help me!

use Win32::Job;
...............................................

$job = Win32::Job->new;

open(FILE_tmp2, ">$PName");
$job->spawn("C:\\Python24\\python.exe", "python BodyTextExtractor.py $PName.txt",
{
stdout => FILE_tmp2,
});
$status = $job->run(60);
close FILE_tmp2;


Thanks a lot!
 
Old 05-03-2007, 06:32 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by cdd
Hi,
I have a perl script that is running in windows environment. This is calling python BodyTextExtractor.
My problem is: I have to move the script to run on linux and I have to change the following part of the script and I don't know how. Please help me!

use Win32::Job;
...............................................

$job = Win32::Job->new;

open(FILE_tmp2, ">$PName");
$job->spawn("C:\\Python24\\python.exe", "python BodyTextExtractor.py $PName.txt",
{
stdout => FILE_tmp2,
});
$status = $job->run(60);
close FILE_tmp2;


Thanks a lot!
if this is just the script you have and no others, why not try to run it in Python.
Just call the BodyText python script using the python interpreter.
#python BodyTextExtractor.py filename
 
Old 05-03-2007, 10:01 PM   #3
Valdis Grinbergs
Member
 
Registered: Dec 2005
Distribution: Debian
Posts: 30

Rep: Reputation: 25
If you really want to call a python script from perl, you could use something like this:

open(STDOUT, ">$PName") || die "Can't redirect stdout";
$status = system("python BodyTextExtractor.py $PName.txt");

Alternately, if you need better control on this subprocess, you might want to look at either IPC::Run3 or IPC::Run (see http://search.cpan.org/~rjbs/IPC-Run...b/IPC/Run3.pm).

Good luck!
 
Old 05-04-2007, 03:08 PM   #4
cdd
LQ Newbie
 
Registered: May 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for the answers.
You really help me a lot!

Thanks again,
cdd
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl script call python -linux cdd Linux - Software 1 05-03-2007 03:45 PM
How to acess Variable defined in perl script inside an awk call sumin Programming 3 04-26-2007 05:19 AM
call perl cgi script from php j-ray Programming 2 01-14-2005 08:23 AM
How to Call a C program from Perl CGI Script anoop_cn Programming 1 05-11-2004 04:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration