LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Inappropriate ioctl for device with perl (https://www.linuxquestions.org/questions/linux-newbie-8/inappropriate-ioctl-for-device-with-perl-725973/)

Punakuono 05-14-2009 10:27 AM

Inappropriate ioctl for device with perl
 
Hi everyone,

I'm writing a basic perl script to write some data to a text file. My script looks like:

#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";

open(File, '>', '/info/info.txt') || die$!;
print FILE "vihtori";
close(FILE);

And the script has 755 rights and so does the text file. If the text file didn't have the right permissions I would get permission denied to the apache server error.log. When the permissions are right I get Inappropriate ioctl device. I have changed the ownership for the file to the user which apache is running. Also the folder where the txt file is belongs to the same user. The script is located in cgi-bin. The strange part is it worked for like 5 minutes before it broke again. I all ready asked from the perl forums for this but their expertise run out when it broke down again and it really seems to be more to do with linux than perl. I'm running the script on debian 5.0 and using perl 5.10.0 and apache 2.2.9.

Help solving this problem would be greatly appreciated. Thank you.

chrism01 05-14-2009 06:54 PM

1. Which distro and version ?
2. Both Linux & Perl are case sensitive(!), so
Code:

#!/usr/bin/perl -w
use strict;

print "Content-Type: text/html\n\n";

open(FILE, '>', '/info/info.txt') or die "Can't open /info/info.txt: $!\n";
print FILE "vihtori\n";
close(FILE) or die "Can't close /info/info.txt: $!\n";

notice the differences between my code and yours. You certainly can't open 'File' and print/close 'FILE';
Best practice is 'or' not '||' for this situation. Use '||' inside if() statements.

3. You need to clarify the ownerships ans permissions on the script and the target file. Please post them eg using ls -l.

4. If you are using Redhat/Centos/Fedora (possibly others) there may be an SELinux issue as well.
Try
ls -Z
on both files as well.

Punakuono 05-15-2009 02:03 AM

1. Which distro and version ?

Linux version 2.6.26-2-686 (Debian 2.6.26-15) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25))


2. Both Linux & Perl are case sensitive(!)
Woops, my copy paste bad. All are FILE in the script...

3. You need to clarify the ownerships ans permissions on the script and the target file. Please post them eg using ls -l.
ls -l kirjotus.pl
-rwxr-xr-x 1 www-data root 232

ls -l info.txt
-rwxr-xr-x 1 www-data root 8

and also for the info directory
drwxr-xr-x 3 www-data root 4096

4. If you are using Redhat/Centos/Fedora (possibly others) there may be an SELinux issue as well.
Try
ls -Z
on both files as well.

I get ? before the file names.

Punakuono 05-15-2009 02:05 AM

To your second point, I did the other changes to the script file tough. Should those error messages show somewhere?


All times are GMT -5. The time now is 04:38 AM.