Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl script in loop ends after one run

Tags:

shell

perl

I am running a Perl script in a loop in a shell script:

  while [ $currentDate -le $toDate ]; do
    // code here...
    exec /users/my_user/script_name $currentDate
    // code here...
  done

I have confirmed the while-loop loops. However, after one run of the Perl script, the while-loop ends.

Could someone please shed some light on this?

like image 450
czchlong Avatar asked Nov 30 '25 19:11

czchlong


1 Answers

You're using exec. exec replaces the shell process with the new program. You probably want to just remove the exec keyword.

exec [-cl] [-a name] [command [arguments ...]] [redirection ...]

Replace the shell with the given command.

Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND.

like image 148
nandhp Avatar answered Dec 06 '25 01:12

nandhp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!