The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:56 AM
Running shell scripts automatically without using Batch or at commands ritzwan0 Shell Programming and Scripting 3 09-17-2006 02:51 PM
Unix commands in perl script athri UNIX for Dummies Questions & Answers 1 07-14-2006 09:31 AM
Perl calling unix system commands new2ss Shell Programming and Scripting 4 04-05-2006 09:32 PM
Replace Perl Module name in all Perl scripts rahulrathod Shell Programming and Scripting 2 12-02-2005 01:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2008
userix userix is offline
Registered User
  
 

Join Date: May 2008
Posts: 21
[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.
  #2 (permalink)  
Old 05-28-2008
FourBrane FourBrane is offline
Registered User
  
 

Join Date: May 2008
Location: Baton Rouge, LA
Posts: 4
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.
Sponsored Links
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0