How to call a function (defined in shell script) in a Perl script

后端 未结 3 1010
旧时难觅i
旧时难觅i 2020-12-19 09:33

I have two scripts, namely shell_script.sh and perl_script.pl.

shell_script.sh : It has function definitions which, when invo

3条回答
  •  梦毁少年i
    2020-12-19 09:46

    To invoke a shell function, the shell needs to know its definition. One way to achieve that is to have the shell first source the file which defines the function. And then, without exiting the shell, call the function. From a Perl script, that would be for example:

    system 'bash', '-c', 'source shell_script.sh; func_1';
    

提交回复
热议问题