Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否为从perl脚本输出的文件和目录设置unix组权限?_Perl_Unix - Fatal编程技术网

是否为从perl脚本输出的文件和目录设置unix组权限?

是否为从perl脚本输出的文件和目录设置unix组权限?,perl,unix,Perl,Unix,除了一个例外,我的脚本就是我想要的。我希望能够自动设置unix组对我在perl脚本中创建的目录和文件的权限 这是可能的,还是我必须求助于 chgrp <group> <directory> chgrp 运行我的脚本后?可以使用Perl的chown函数: # Get the GID as a number my $gid = getgrnam("group"); # Change the ownership chown -1, $gid, $dir; # Or $

除了一个例外,我的脚本就是我想要的。我希望能够自动设置unix组对我在perl脚本中创建的目录和文件的权限

这是可能的,还是我必须求助于

chgrp <group> <directory>
chgrp

运行我的脚本后?

可以使用Perl的
chown
函数:

# Get the GID as a number 
my $gid = getgrnam("group");

# Change the ownership 
chown -1, $gid, $dir; # Or $file or @list_of_files depending on your need
但是,您可能需要特权才能执行此操作,如文档中所述。