The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl CGI Scripts cb.mark High Level Programming 1 11-23-2006 06:56 AM
Running shell scripts automatically without using Batch or at commands ritzwan0 Shell Programming and Scripting 3 09-17-2006 11:51 AM
Unix commands in perl script athri UNIX for Dummies Questions & Answers 1 07-14-2006 06:31 AM
Perl calling unix system commands new2ss Shell Programming and Scripting 4 04-05-2006 06:32 PM
Replace Perl Module name in all Perl scripts rahulrathod Shell Programming and Scripting 2 12-01-2005 09:00 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-28-2008
Registered User
 

Join Date: May 2008
Posts: 16
[PERL] Running unix commands within Perl Scripts

I understand that in order to run basic unix commands I would normally type at the prompt, I would have to use the following format
Code:
system(ls -l);
or
exec(ls -l);
But when I actually try to use the command, the script fails to compile and keeps telling me there is an error with this line. How exactly do I run commands in perl? I have the proper shebang that points to the perl exec. Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-28-2008
Registered User
 

Join Date: May 2008
Posts: 3
system calls

To learn more about the perl system function, at your command line type
perldoc -f system

(to learn more about using perldoc, type 'man perldoc' at the command prompt).

Your problem is that system() is expecting a LIST of things you want done. You are providing it with two items which aren't even separated by a comma, so Perl is going crazy trying to figure out what you want.

Try system("ls -l") to provide system() with just one thing you want it to do. Same with exec. Be sure to perldoc -f exec to discover the differences between these two commands.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:56 AM.


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

Content Relevant URLs by vBSEO 3.2.0