LinuxQuestions.org
Visit Jeremy's Blog.
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 11-28-2010, 07:53 PM   #1
garyg007
Member
 
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
Code:
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";
					}		
				else
					{
					 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
Code:
gary@debian:~/Desktop$ ./tc-inprocess --dir /Video/Mythtv_Recorded --filename 2245_20101127200000.mpg --chanid 2245 --starttime 20101127200000
	Query results:
================================================

CALLING MYTHCOMMFLAG

Message from sys:...

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

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

Code:
system ("mythcommflag -c $chanid -s $starttime");
 
2 members found this post helpful.
Old 11-28-2010, 10:01 PM   #3
garyg007
Member
 
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.

Gary
 
  


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

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

All times are GMT -5. The time now is 02:39 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