perl 實現shell 命令的檔案儲存操作

season0891發表於2008-10-30

my $file="test.txt";

my $cmd="ls";
open(FILE,"> ".$file);
print FILE $cmd."\n";
system($cmd." >>$file");
close(FILE);

$cmd="date";
open(FILE,">> ".$file);
print FILE $cmd."\n";
system($cmd." >>$file");
close(FILE);

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-481931/,如需轉載,請註明出處,否則將追究法律責任。

相關文章