Hi Rob. I'm trying to help. Really I am. But first of all it looks like you should be writing a bash script file (Perl isn't a scripting language).
Please explain: Rmck wrote: > > I have a script that I what the last part of the element of > an array? So I can restart the script with the same element. > Help: > > #!/bin/perl > use strict; > > # Need IP of current procees so I can re-start it. > # How it is returned: > # root 6762 1355 0 Oct 05 pts/2 0:00 /bin/perl -w ./script.pl > 211.211.111.111 > # > > my @ip = `ps -ef|grep script.pl|grep -v grep`; This will grab the output of the command line into a Perl array '@ip' of output records. You seem to be doing this so that you can get the PID '6762' from the output? > # Grab PID of current procees so I can kill it. > # How it is returned: > #6762 > # > my @script = `pgrep script.pl`; OK, now you're getting the output records of another command into another array '@script' which you never use again. You seem to be doing this so that you can get the PID '6762' from the output in a different way? > foreach (@nab) { > print("Killing $_\n"); > } You're printing the contents of Perl array @nab (which you haven't used before) saying that each element has been 'killed'. The array is empty and this will output nothing. > foreach (@ip){ > print "/opt/script.pl $_\n"; > } And now you're printing the contents of '@ip' with each record prefixed with '/opt/script.pl ' and an additional newline appended. > ############### > > > whats displayed: > > bash-2.03# ./ks.pl > Killing 6762 > > /opt/script.pl root 6762 1355 0 Oct 08 pts/2 0:00 /bin/perl -w > ./script.pl 211.211.111.111 > > bash-2.03# > > I would lilke it to: > bash-2.03# ./ks.pl > Killing 6762 > > /opt/script.pl 211.211.111.111 & > > bash-2.03# This part I don't understand at all. Perhaps others do? What is 'ks.pl'? Is it the name of the Perl script that you've shown us? > Please advise...And of course thanks You're writing a Perl program which essentially runs 'ps' and prints the output slightly reformatted. Try to explain what it is you want to do. And I still think you should be writing a bash script! I hope this helps in some way. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]