Reputation: 510
I have a perl script that is executed by the Jenkins CI, but when it tries to execute the following code i get a "Inappropriate ioctl for device" error.
$) = $new_group;
if($!){
print STDERR $! . "\n";
print STDERR "Failure to change permissions to: Gid: $new_group \n";
next;
}
$> = $new_user;
if($!){
print STDERR $! . "\n";
print STDERR "Failure to change permissions to: Uid: $new_user \n";
next;
}
But while if a do the same manually like this, i receive no error
perl -e '$) = 99; if($!){print $! ."\n";} $> = 99; if($!){print $!."\n";}print `whoami`;'
Any clues why this error occures, and what i means? I have search the net, but it seems to occur when filehandlers are open, havnt seen any examples on it occuring when changing users.
All scripts are executed as root.
Upvotes: 0
Views: 639
Reputation: 11
$! is only useful directly after a failed system call. When setting the group or user is successful, you don't really know what will be in $!, and can't rely on it being a false value. You might trying using 'or die ' when setting the user and group, or maybe just comparing $) and $> to $new_group and $new_user again after you attempt to set them.
Upvotes: 1
Reputation: 5069
To debug the code, use this method, and see whats going on. Print out each variable content when you receive an error. Please use strict and warnings, they heelp you a lot!
Please include the output if you cannot solve this problem with this method.
use strict;
use warnings;
use Data::Dumper;
$) = $new_group;
warn "\$), \$new_group: ".Dumper($),$new_group);
...
Upvotes: 0