Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-28-2010, 08:53 PM   #1
Registered: Aug 2008
Location: north-east ohio
Distribution: Debian-squeeze/stable;
Posts: 279
Blog Entries: 1

Rep: Reputation: 31
Perl question - executing a linux binary program

I am in the process of teaching myself Perl.
A few things have really stumped me - one I have not yet resolved.

I want to run an executable from a perl script and have any printout from the executable show on the console from which I ran the perl script

This a portion of the code where I want to run the executable
print "\tQuery results:\n================================================\n";	
$numselected = 0;

while ( my @row = $sth->fetchrow_array( ) )  
	{       $chanid = $row[0];
	        $starttime = $row[1];
		my $title = $row[2];
		my $cf = $row[3];
		my $cl = $row[4];
		my $basename = $row[5];
		my $subtitle = $row[6];
#		print "$row[0] . $row[1] . $row[2] . $row[3] . $row[4] . $row[5]\n";		
if  ($basename =~ /$filename/ && !$cf )
#                              	print "\nbasename=$basename.......filename=$filename\n";
#	       			print "$row[0] . $row[1] . $row[2] . $row[3] . $row[4] . $row[5]\n"; 
				$numselected = $numselected + 1;   
				if (!$cf) 
					 print "\nCALLING MYTHCOMMFLAG\n";
					 `mythcommflag -c $chanid -s $starttime`;
					 print "\nMessage from sys:...$!\n";
					 print "\n PROGRAM LOGIC ERROR\n";
					 exit 255;
print "\nTotal rows selected: $numselected\n"
Here is the output of what I have (no evidance that the executable has actually run
gary@debian:~/Desktop$ ./tc-inprocess --dir /Video/Mythtv_Recorded --filename 2245_20101127200000.mpg --chanid 2245 --starttime 20101127200000
	Query results:


Message from sys:...

Total rows selected: 1
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-28-2010, 09:17 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Try "system()":

system ("mythcommflag -c $chanid -s $starttime");
2 members found this post helpful.
Old 11-28-2010, 11:01 PM   #3
Registered: Aug 2008
Location: north-east ohio
Distribution: Debian-squeeze/stable;
Posts: 279

Original Poster
Blog Entries: 1

Rep: Reputation: 31
Thankyou paulsm4;

So far my main problem is getting all the "special characters" sorted out.



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
Binary not executing belmonthengoed Linux - Software 4 02-01-2006 07:13 AM
executing binary issues +0+4|_ n00b Linux - Newbie 1 03-04-2005 02:55 PM
executing binary problems. cheater1034 Linux - Software 2 09-18-2004 12:08 PM
Executing a program on server using CGi/PERl ?! avios Red Hat 1 12-29-2003 03:34 AM > Forums > Non-*NIX Forums > Programming

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

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