in reply to Run Linux Command from Perl Script

Have a look at the documentation for system. Unlike virtually everything else, it returns non-zero for failure, so where you say "system || print "error"", you need to have something more like:

system( "sh $temp_shell2" ) == 0 or die "2 failed to execute: $!";

I think right now it's telling you that it fails when it's not.