任何人都可以告訴我,如何在Perl腳本中使用shell命令結果?如何在perl腳本中使用shell命令?
#!/usr/bin/perl
$whoami=`whoami`;
system ('cd /var/home/'.$whoami.'/htdocs');
print $whoami;
腳本輸出
[[email protected] _1]$ ./sys.pl
sh: line 1: /htdocs: No such file or directory
user1
我想改變目錄到/ var /家庭/用戶1/htdocs目錄
請注意,沒有一個解決方案(更正後的代碼)將改變你的程序的工作目錄! – pavel 2012-02-27 13:22:19