LinuxQuestions.org
Help answer threads with 0 replies.
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, 04: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, 07:32 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
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, 11: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, 04: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:45 PM
How to acess Variable defined in perl script inside an awk call sumin Programming 3 04-26-2007 06:19 AM
call perl cgi script from php j-ray Programming 2 01-14-2005 09:23 AM
How to Call a C program from Perl CGI Script anoop_cn Programming 1 05-11-2004 05:37 PM


All times are GMT -5. The time now is 01:15 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration