+ -
当前位置:首页 → 问答吧 → 在perl脚本中运行命令出错

在perl脚本中运行命令出错

时间:2011-08-08

来源:互联网

想再perl脚本中运行这样一条命令:
for PART in `grep -v ^# /etc/fstab | awk '($6 != "0"){print $2}'`;do find $PART \( -perm -04000 -o -perm -02000 \) -type f -xdev -print ;done
怎么写啊?

我这么写的:
system "for PART in `grep -v ^# /etc/fstab | awk '($6 != \"0\"){print $2}'`;do find $PART \( -perm -04000 -o -perm -02000 \) -type f -xdev -print ;done";

结果不对,我刚开始学perl,求论坛大牛指正。谢谢了

作者: gd1214   发布时间: 2011-08-08

Perl code
#! /usr/bin/perl
use strict;

my $cmd = q[for PART in `grep -v ^# /etc/fstab | awk '($6 != "0"){print $2}'`;do find $PART \( -perm -04000 -o -perm -02000 \) -type f -xdev -print ;done];                      

system($cmd);

作者: will2ni   发布时间: 2011-08-08