简体   繁体   English

从perl在linux中运行程序

[英]running a program in linux from perl

I want to run a program from perl by using system command(or any other ways ). 我想通过使用系统命令(或任何其他方式)从perl运行程序。

system("samtools"); 系统( “samtools”);

I think it should pass this to shell but it complains ,Can't exec "samtools" file or directory does not exist , when I run it.I have tried many other different program for example 我认为它应该传递给shell但它抱怨,不能exec“samtools”文件或目录不存在,当我运行它。我已经尝试了许多其他不同的程序,例如

system("velveth"); 系统( “velveth”);

and it works properly but not this one (samtools). 它运作正常但不是这个(samtools)。 Is any of you facing this problem before? 你们中间有人面临这个问题吗? I am really puzzled. 我真的很困惑。

You can give the full path to that file location. 您可以提供该文件位置的完整路径

example: 例:

system( "/usr/bin/perl -de 1");

Try putting Linux command inside `` characters. 尝试将Linux命令放在``字符中。 Will work as well. 也会工作。

Did you modify $path for samtools in the current shell manually? 您是否手动修改了当前shell中的samtools $path

Since system starts a new sub-shell to run your command, you have to append search path for samtools yourself if doesn't exist in your .bashrc . 由于system启动一个新的子shell来运行你的命令,你必须自己附加samtools搜索路径,如果你的.bashrc中不存在。 Check it by: 检查:

perl -e 'system("echo \$PATH")'

and

echo $PATH

to see if there's any difference. 看看是否有任何区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM