calling Perl from C


 
Thread Tools Search this Thread
Top Forums Programming calling Perl from C
# 1  
Old 12-06-2001
Tools 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.
# 2  
Old 12-07-2001
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
shaik786
# 3  
Old 12-12-2001
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

Smilie
# 4  
Old 04-01-2009
Question

How to pass the return value to C program?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling perl from shell script

I am calling a perl script from shell script. $ cat mah_appln_bkp_oln.ksh #!/bin/ksh . /udb/home/udbappln/.profile . /udb/home/udbappln/sqllib/db2profile Com=/udb/udbappln/utility/systemscripts/currentUMR perl $Com/backup.pl -d dbname --tsm --purgetsmcopies 21 --purgetsmlogs exit 0 ... (1 Reply)
Discussion started by: ilugopal
1 Replies

2. Shell Programming and Scripting

Perl Methods Calling

Hello I am on my way to improve my wonderful Perl skills, I got an issue which I want to share with you all. I have a Perl module which looks like package Cocoa; require Exporter; @ISA = qw(Exporter); my $a=''; my $b=''; my $c=''; sub new { my $this = shift; # Create... (8 Replies)
Discussion started by: adisky123
8 Replies

3. Shell Programming and Scripting

PERL: Function calling using parameters

I have two variables. I need to call them using the same function my $dat1 ="abc"; my $dat2 ="def"; my $check; filecheck($dat1,$dat2); sub filecheck($) { $check = shift; print "first name is $check\n"; } print "this is fine\n"; sub filecheck($) { $check = shift; print "second... (2 Replies)
Discussion started by: irudayaraj
2 Replies

4. Shell Programming and Scripting

calling perl subroutine from perl expect module

All, Is it possible to call a subroutine from the perl expect module after logging to a system that is within the same program. My situation is I need to run a logic inside a machine that I'm logging in using the expect module, the logic is also available in the same expect program. Thanks,... (5 Replies)
Discussion started by: arun_maffy
5 Replies

5. Shell Programming and Scripting

calling perl commands in shell

i have four commands 1. perl -MCPAN -e shell 2. o conf prerequisites_policy follow 3. o conf commit 4. exit I am attempting to streamline a bunch of yum commands and cpan installations and want to remove the confirmation portion of the cpan these four commands will do just that. my... (2 Replies)
Discussion started by: murphybr
2 Replies

6. Shell Programming and Scripting

Calling 3 perl script from one

hi all, I have 3 perl scripts a.pl,b.pl and c.pl each of these work when i pass a date for eg: perl c.pl 2010-05-27 now i want to write a perl script that would call the 3 scripts and make it run all the 3 scripts (a.pl,b.pl,c.pl) parallelly rather than 1 after the other....... pls... (2 Replies)
Discussion started by: siva_nagarajan
2 Replies

7. Shell Programming and Scripting

calling problem in perl script

Hi , Here is my piece of code-- main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, ... (1 Reply)
Discussion started by: namishtiwari
1 Replies

8. Shell Programming and Scripting

Calling Expect script in Perl...

I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. The values to be exported or stored in a file. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line, Now I could like... (4 Replies)
Discussion started by: ramkriz
4 Replies

9. Shell Programming and Scripting

calling a shell script from perl

Hi all, Not sure if this is the right forum to post query regarding perl script. I have a perl script which internally calls a shell script. My problem is that the shell script should be passed command line arguments. I call a shell script from perl using: system("sript.sh"); How do... (3 Replies)
Discussion started by: gurukottur
3 Replies

10. Shell Programming and Scripting

URL calling in PERL

All Please help me to call url in Perl. Ex: http://www.test.com/dynf?urn=123 Assume it will return success if 123 is in urn or it will return " failed". I want store this return type in a variable. Please help me to call the URL through PERL. Thanx in advance Regards Deepak (1 Reply)
Discussion started by: DeepakXavier
1 Replies
Login or Register to Ask a Question