perl - understand process status and continue the code execution
Hello, I need advice on how to check if started processes are finished in perl, here's explanation :
OS is RHEL 4, perl -v = "This is perl, v5.8.0 built for i386-linux-thread-multi"
The logic of the script :
Pretty simple, given that I'm not so good at perl, I wrote that for test.
So, what I'm basically doing is starting file transfers via ssh or other protocol with custom binary, and I need to check somehow that the transfers are done and then continue with other code executiom, in my case that will be another subroutine call, doing some static stuff. Quering the OS with "system ("pgrep pattern") every 1 second doesn't seem good, so I'm thinking of using fork() in order to trap the transfers' end. If that's the right way, I guess it should look like :
I've read the documentation for fork(); but I'm not sure if that's the right way. I guess my issue is that the file size vary from 10kb to 10Gb sometimes and I can't predict time to wait (using sleep for example). I'll appreciate any pointers.
Thanks cbkihong, I saw that already, this would probably require fork(); but it won't work for me, at least in the way I wanted, I have arbitrary number of processes started via system command, and I can't use their PIDs, plus the execution of the subroutine call itself is successful, so I cannot do even :
I think I'll wait for STDIN interaction while "chomp"-ing the input, this should ensure that processes / SSH transfers in the background are done, assuming someone is looking at the external log file in real time.
Hi all,
I have a EFI disk and it is use in zfs pool.
partition> p
Volume: rpool
Current partition table (original):
Total disk sectors available: 1172107117 + 16384 (reserved sectors)
Part Tag Flag First Sector Size Last Sector
0 usr wm ... (8 Replies)
Hi,
I am working on a file copier utility where I have written the copy commands to a batch file e.g. file_copier.bat which i pass to xargs command as follows.
cat file_copier.bat | xargs -n 1 -P 40
I also want to record the copy command status of each file/command in the form "command... (1 Reply)
Hi all.
I have a script like this
function check_filesize {
filesize_1="$(ls -la "$1"|awk '{ print $5 }')"
sleep 123
filesize_2="$(ls -la "$1"|awk '{ print $5 }')"
if
then
echo "OK"
else
echo "NOT OK"
sleep 1234
check_filesize $1
fi
}
function check_TR {
chk="$(tail -1 $1|grep... (5 Replies)
Hi Friends,
Iam invoking another shell script to create B2k_session_id from my shell script.It is properly creating B2k_session_id and after creation control is coming out from the script and going to command prompt.The lines which are after the exectrusteduser.com sh.com are not executing..may... (5 Replies)
Hello,
I'm writing script to parse configuration files in perl. I would like to enable regular expressions as part of configuration file. I.e I would like to enable the users to select files that will be proceeded by the script using regex. I was wondering, is it possible for the user to execute... (4 Replies)
Hello All,
Good day! This is my first UNIX post. :D
Anyways, I would like to seek help from you guys if you know of any UNIX command that will skip a warning message once it is encountered but continue to run the execution.
Ok here's the situation in general:
An encypted file is sent to... (2 Replies)
HI ,
I am new to the perl , I am using a if condition and in that if condition i am checking 7 variables value. so it continue to second line .And if i user "\" for the continue line it showing error.
Example :
if(a >9 || b>8 || c> 10 \
d > 11)
{
print();
}
The above statement is... (3 Replies)
Lets say a user starts a process (either a shell script or a Perl script) and before that process finishes, he logs out (either intentionaly or network problems or ...), does the process continu running ?
Default shell is Korn.
This is because at my job (being trained), there are tasks to run... (2 Replies)
Hello people,
I am using KSH and inside my script I do a cksum and check the status code to see whether the command sucessfully. Here even though the cksum fails due to file not existing the status returned is still 0 because the awk command worked fine. How do I capture just the status of the... (1 Reply)