perl and unix command

L

lerameur

Hello,

I am writting a perl scipt in unix and I will invoking some unix
commands in my script. If the first command takes a few minutes to
process, how do I make sure the second command do not start until the
first command is finished ?


thanks
ken
 
T

Tony Curtis

lerameur said:
Hello,

I am writting a perl scipt in unix and I will invoking some unix
commands in my script. If the first command takes a few minutes to
process, how do I make sure the second command do not start until the
first command is finished ?

perldoc -f system
 
L

lerameur

At 2007-09-20 09:39AM, "lerameur" wrote:




As you're using google already, you might want to use its search
function. I hear its pretty good...


google?
1,680,000 results, most of them refering to unix command in perl, in
the one I looked, have not seen any with execution time analysis
between commands.
maybe you have googled one

k
 
T

Tony Curtis

lerameur said:
google?
1,680,000 results, most of them refering to unix command in perl, in
the one I looked, have not seen any with execution time analysis
between commands.
maybe you have googled one

You didn't ask about "execution time analysis".

Show us an example of what you're trying to do.
 
L

lerameur

You didn't ask about "execution time analysis".

Show us an example of what you're trying to do.

I though I did in the first message.
Example:
scan_log.pl
rm *.log

here are the two unix command I want to put in a perl script, The scan
log script can take 2 minutes to do the scan. I want to make sure the
rm *.log command to starts after the scan_log. I am scared that once
the scan_log.pl has been read, the script will go to the next line and
run the rm *.log command before the scan_log.pl has finished scanning.

ken
 
J

Josef Moellers

lerameur said:
I though I did in the first message.
Example:



here are the two unix command I want to put in a perl script, The scan
log script can take 2 minutes to do the scan. I want to make sure the
rm *.log command to starts after the scan_log. I am scared that once
the scan_log.pl has been read, the script will go to the next line and
run the rm *.log command before the scan_log.pl has finished scanning.

The system() function will not return until the command within has
terminated. Beware that if you write something like
system("scan_log.pl&");
then "the command within" is a shell, which in turn starts scan_log.pl
without waiting for it and thus will terminate before scan_log.pl has
finished.

I.e.
system("scan_log.pl");
system("rm *.log");
will be what you want.
 
L

lerameur

The system() function will not return until the command within has
terminated. Beware that if you write something like
system("scan_log.pl&");
then "the command within" is a shell, which in turn starts scan_log.pl
without waiting for it and thus will terminate before scan_log.pl has
finished.

I.e.
system("scan_log.pl");
system("rm *.log");
will be what you want.
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details:http://www.fujitsu-siemens.com/imprint.html

ok thank you

k
 
T

Ted Zlatanov

l> I am writting a perl scipt in unix and I will invoking some unix
l> commands in my script. If the first command takes a few minutes to
l> process, how do I make sure the second command do not start until the
l> first command is finished ?

This is what will happen by default, unless the first command takes
special measures to detach itself and run in the background.

In Unix terms, the Perl process running the command is waiting for the
child process to exit every time it calls system(). There's more to the
picture (there are different ways to call system() for instance), but
this is the essential idea.

Ted
 
X

xhoster

lerameur said:
..

/>perldoc -f system
ksh: perldoc: not found

Install Perl on your system.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
J

John W. Krahn

Sherm said:
Try "man system" - Perl docs are often installed as man pages also.

That will probably get you the system(3) man page instead of Perl's system
function (although they basicly do the same thing.)

"man perlfunc" will get you the listing for Perl's system function.

Also, check to see if your OS has a "perl-docs" or similar port|rpm|deb
or other package. Some vendors like to split Perl into multiple packages,
with separate developer and docs packages.

Kubuntu does this. I had to manually install a lot of stuff.




John
 
L

lerameur

That will probably get you the system(3) man page instead of Perl's system
function (although they basicly do the same thing.)

"man perlfunc" will get you the listing for Perl's system function.


Kubuntu does this. I had to manually install a lot of stuff.

John

I am running on sunOS 5.9 (solaris)
I do not know unix that much, so I do not know if it is a perl issue
with that specific OS.
"man perlfunc" do not work by the way
k
 
C

Chris Davies

lerameur said:
I am running on sunOS 5.9 (solaris)
I do not know unix that much, so I do not know if it is a perl issue
with that specific OS.

It's a Solaris issue. Perl is installed into /usr/perl5/5.6.1 but only
perl itself is symlinked back into /usr/bin.

Two solutions, either of which will work:

(a) Add this statement to your ".profile" either near the top, or
immediately after the last line starting "PATH=" (if there is one):

PATH="/usr/perl5/5.6.1/bin:$PATH" export PATH

To make the change effective immediately, also type it directly at
the command prompt (just this once)

(b) Ask your System Administrator to complete Sun's botched installation
of perl, by adding its commands to /usr/bin, with a command such as
this:

cd /usr/bin && ln -s ../perl5/5.6.1/* .

This command will complain that perl already exists - don't worry
about that. Don't forget the trailing dot!!

Hope this helps,
Chris
 
L

lerameur

the command:
PATH="/usr/perl5/5.6.1/bin:$PATH" export PATH

works great. I have access to my perldoc pages.
thanks

ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top