#!/usr/bin/perl
#
#fork.pl
#------
#Simple example of some code that creates processes using the fork() system call.
#A number of other system calls are also made. They are getuid() which returns the
#numeric userid of the user executing the process, getpid() which returns the
#numeric process id (PID) of the process, sleep() which causes the process to sleep for
#designated number of seconds, and exit() which terminates the program with the
#specified completion status (zero is normal completion. For those unfamiliar with C,
#the %d format code used in the print() call causes an integer variable to be formatted
#for output as a decimal ('d') number.
main:
{
my ($i, $pid);
for ($i=0;$i<3;$i++) {
printf("Parent process before the fork, uid= %d, pid=%dn",$>,$$);
$pid=fork();
if ($pid!=0) {
# /* parent process executes here */
printf(„Parent process after the fork, uid= %d, pid=%dn”,$>,$$);
}
else {
# /* child process execute here */
printf(„Child process after the fork, uid= %d, pid=%dn”,$>, $$);
sleep(1);
printf(„Child process exiting, uid= %d, pid=%dn”,$>, $$);
exit(0);
}
} #/* end for */
printf(„Parent process exiting, uid= %d, pid=%dn”,$>, $$);
} #/* end main */
#!/usr/bin/perl
#exec.c
#------
#Simple example of some code that causes a running process to execute a different
#program (in this case, the 'date' program which prints the current date and time).
#Handling of an error situation is also illustrated.
main:
{
my( $i,$rc);
for ($i=0;$i<3;$i++) {
if (($i % 2) == 0) { #/* if i is an even number try to invoke an unknown program */
$rc=system(„unknownprogram”);
}
else {# /* i is odd so invoke the date program */
$rc=system(„/bin/date”);
}
if ($rc!=0) {
printf(„Error - unknown program.n”);
}
} #/* end for */
printf(„About to exit the 'exec' program.n”);
} #/* end exec */
Treba da uradim kombinaciju ova dva programam ali gledao sam one primere ali nije nije sličan onome sto mi treba.
Iskreno ne poznajem perl toliko dobro ali ovo mi je vrlo hitno inače puce mi jedan module..
Kako da editujem ova dva programar da rade ono sto želim?
Pozdrav
P.S. Alex molim te pomogni mi.Treba da dam ovaj rad u ponedeljak ali nemam ideju kako to da uradim.
If u can do it i can do it as well