HarshV has asked for the wisdom of the Perl Monks concerning the following question:

Hey guys, I have read many threads for this question, but couldn't succeed. I have a shell script in which I am trying to call a perl script. It's just going to be one liner command. The exit code this command generates is 2. Not sure, what's this. Any help is appreciated. I had tried few ways: 1) perl path/to/the/script/ABC.pl 2) path/to/the/script/ABC.pl 3) path//to//the//script//ABC.pl

Replies are listed 'Best First'.
Re: Perl in Shell
by Anonymous Monk on Sep 23, 2014 at 15:20 UTC

    I assume this is *NIX and not Windows?

    Your (1) should work if perl is in your PATH, (2) should work if the script has executable permissions and starts with a shebang line appropriate for your system (e.g. "#!/usr/bin/perl" or "#!/usr/bin/env perl"), (3) might work but isn't preferable, the extra slashes don't do anything but add confusion.

    However, this isn't a "one liner". A one-liner would be something like perl -e 'print "Hello, World!"' (i.e. the entire program is on the command line and not in a file)

    See also Running Perl programs

    Please see How do I post a question effectively?: Please show your shell script (wrapped in <code> tags), as well as the error messages you're getting (if any).

Re: Perl in Shell
by Anonymous Monk on Sep 23, 2014 at 19:04 UTC

    Please mark updates to your node, see How do I change/delete my post?. Without knowing what your code looks like, we don't know what could be causing an exit code of 2 (perhaps exit 2;?). Please show your code, or reduce your code down to a small, self-contained example that reproduces the problem.