Find the answer to your Linux question:
Results 1 to 4 of 4
Hello All, We are going to migrate from Unix to Linux . In unix we can directly call the perl script by specifying the name . But when we call ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    6

    How to call a perl script from Linux shell script

    Hello All,

    We are going to migrate from Unix to Linux . In unix we can directly call the perl script by specifying the name . But when we call perl script in the same way in Linux from shell script , It gives error like "scriptname : not found [No such file or directory]" .

    So I want to know how we can call the perl script from Linux shell script sothat this error is rectified and perl script runs as expected.

    Thanks in Advanve !!

  2. #2
    Just Joined!
    Join Date
    Jun 2006
    Posts
    40
    Hi ISHA,

    On your linux console do a command "which perl" which will give you certainly the path of your perl executable as "/usr/bin/perl" (though the path of perl executable may differ, depending upon where your perl executable has been installed, generally it should be as /usr/bin/perl)

    You can then implement this into your shell script by writing the 1st line in your shell script as:
    #!/usr/bin/perl -w

    #Then try using below line in your shell script as below, you can also
    #use the absolute path of your perlscript.pl
    /usr/bin/perl perlscript.pl

    Try this...and let me know, if the problem still resists.

    Thanks
    Pawan S.

  3. #3
    Just Joined! neirons's Avatar
    Join Date
    Nov 2006
    Location
    Latvia, Liepaja
    Posts
    18
    #!/bin/bash

    # test.sh

    # Simple execute Perl script from Bash sckrip.
    # Executed srcipt do work as expected
    #
    # hello.pl source:
    #
    # #!/usr/bin/perl

    # print "Hello World!\n";


    clear
    exec ~/00/hello.pl

    # Terminal is cleared and
    # after Perl script is done, string: Hello World! is writed.
    # Perl script should have execute attribute: chmod ug+x ~/00/hello.pl

    So, actualy You don't need nothing special to execute Perl scripts from Bash script. Try to find out a problem source. Check Perl script attributes.

  4. #4
    Just Joined!
    Join Date
    Nov 2008
    Posts
    6

    Problem solved Thanks a Lot

    Pankaj and Neirons thanks a lot , because of the information provided by you I could resolve that problem by calling the perl script as below from the shell script:

    /user/bin/perl perlscriptname

    Thanks again !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...