Execute shell script even if the first script fails

All,

I executing a perl script and shell script from a master shell script. i will execute the perl script first and have to execute the shell script after the completion of perl execution. Below is the code i use for it,

script_root='/dev/scripts'
/usr/bin/perl -S $script_root/test.pl; $script_root/test.sh

This is working fine. But if add redirect to log for the perl script, i get the below error

syntax error near unexpected token `;'

But if add redirect to log for the perl script, i get the below error

post the code of redirection

Please find it here,

/usr/bin/perl -S $script_root/test.pl >> log/perl_srt.log_$(date +\%F) 2>&1 &; $script_root/test.sh

you are executing the perl script in background.

you can do like this..

 
/usr/bin/perl -S $script_root/test.pl >> log/perl_srt.log_$(date +%F) 2>&1
wait
$script_root/test.sh

Thank you. Will it execute test.sh even if test.pl fails and returns exit 1.

 
$ cat f.sh
#!/bin/bash
echo "Shell Script"
exit 1
 
$ cat f.pl
#!/bin/perl
print "PERL Script";
exit 1;
 
$ cat g.sh
#!/bin/bash
bash f.sh
wait
perl f.pl
echo "Complete"
 
$ bash g.sh
Shell Script
PERL ScriptComplete
1 Like