can we source a shell script in perl script

前端 未结 7 838
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 04:54

can we source a shell script in the perl script??

Example: Program 1:

cat test1.sh
#!/bin/ksh
DATE=/bin/date

program 2:

<         


        
7条回答
  •  醉话见心
    2021-01-15 05:28

    You can do something simple, like this:

    system "source /path/to/shell_env.sh &&"
         . "/path/to/script.sh";
    

    NOTE that this is different than the following which is not recommended:

       system "source /path/to/shell_env.sh &&"
            . "/bin/sh /path/to/script.sh";
    

提交回复
热议问题