The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Calling Winzip from perl script MobileUser Shell Programming and Scripting 5 04-04-2007 12:51 AM
calling a shell script from perl gurukottur Shell Programming and Scripting 3 10-05-2006 08:48 AM
Perl calling unix system commands new2ss Shell Programming and Scripting 4 04-05-2006 06:32 PM
URL calling in PERL DeepakXavier Shell Programming and Scripting 1 01-04-2006 08:29 AM
Calling perl modules from shell scritps kavitha Shell Programming and Scripting 1 03-31-2004 11:34 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-06-2001
Registered User
 

Join Date: Nov 2001
Posts: 4
Cool calling Perl from C

Hi,

I am trying to execute a perl script from c program.
I tried using system command.

system("perl test.pl filename") ;

This perl program takes filename as input and prints a number
to screen.

I need to get that returned number in C program.
system command is executing perl program, but I am not
able to get the return number. How I can get the return
value in c.

Thanks,
kk.
Reply With Quote
Forum Sponsor
  #2  
Old 12-06-2001
shaik786
Guest
 

Posts: n/a
Hi!

Two simple ways of getting the output are:

1.) system("perl test.pl filename > output.txt"); ----> and then open the file output.txt and read it for the output.

2.) popen("perl test.pl filename", "r"); and read the output, which is the method I suggest. ----> See the man pages of popen()

Rgds
SHAIK
Reply With Quote
  #3  
Old 12-12-2001
Registered User
 

Join Date: Oct 2001
Location: Bangalore
Posts: 93
u dont even need to use
system("perl test.pl filename") ;

better put the first line of your PERL file as #!/usr/bin/perl

then u can directly use

system("test.pl filename >output")
and then read from this output file

Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0