LinuxQuestions.org
Help answer threads with 0 replies.
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 01-20-2005, 01:01 AM   #1
Palamides
Member
 
Registered: Jan 2005
Posts: 104

Rep: Reputation: 15
Perl question


does anyone know what the command is to print something out to the shell command line...
for example if i run a program and i want it to execute another program with certain arguments depending on the outcome of the program, once itś done running. Does anyone know what the code would look like to perform such a task if its evne possible? thanks
 
Old 01-20-2005, 04:49 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
It sure is. The command "exec" will replace the current process (the perl script) with the shell and will run whatever command you put in it.

e.g. exec "ls -l $file_decided_on_by perl_script";

The command "system" does the same thing except it generates a new process.

John
 
Old 01-20-2005, 10:13 AM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
see also http://sial.org/howto/perl/backticks/ and google("perl backtick") or google("perl backstick").
 
Old 01-20-2005, 03:57 PM   #4
Palamides
Member
 
Registered: Jan 2005
Posts: 104

Original Poster
Rep: Reputation: 15
thanks a lot!
 
Old 01-20-2005, 09:50 PM   #5
Palamides
Member
 
Registered: Jan 2005
Posts: 104

Original Poster
Rep: Reputation: 15
i have another question for example i have this code:


$x=0;

for($x=1000; $x<=9999; $x++)
{
exec "/usr/local/programToBeExecuted $x";
}



when i execute this, for some reason it only executes the 'exec "/usr/local/programToBeExecuted $x";' once so itd be like #program 1000 in the command line.
then it stops

anyone know why?

Last edited by Palamides; 01-20-2005 at 09:52 PM.
 
Old 01-21-2005, 12:35 AM   #6
dustu76
Member
 
Registered: Sep 2004
Distribution: OpenSuSe
Posts: 153

Rep: Reputation: 30
Just read the post by jkobrien. He made the reason amply clear.

This is not a repair shop. Read & understand the posts.
 
Old 01-21-2005, 01:09 AM   #7
Palamides
Member
 
Registered: Jan 2005
Posts: 104

Original Poster
Rep: Reputation: 15
my bad missed the "system" part, thanks a lot it worked perfectly

Last edited by Palamides; 01-21-2005 at 01:19 AM.
 
  


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
a perl question thanhVic Programming 1 03-13-2005 02:45 AM
a perl question thanhVic Linux - Newbie 2 03-12-2005 05:04 PM
Hiding code in PERL, perl gui question randomx Programming 1 06-26-2004 03:22 PM
perl question eph Programming 4 04-04-2004 09:51 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

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

All times are GMT -5. The time now is 02:56 PM.

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