LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2009, 10:27 AM   #1
Punakuono
LQ Newbie
 
Registered: May 2009
Posts: 3

Rep: Reputation: 0
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.
 
Old 05-14-2009, 06:54 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
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.
 
Old 05-15-2009, 02:03 AM   #3
Punakuono
LQ Newbie
 
Registered: May 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 05-15-2009, 02:05 AM   #4
Punakuono
LQ Newbie
 
Registered: May 2009
Posts: 3

Original Poster
Rep: Reputation: 0
To your second point, I did the other changes to the script file tough. Should those error messages show somewhere?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Perl error with "Inappropriate ioctl for device" bnutting Programming 9 03-12-2012 07:25 AM
inappropriate ioctl for device praetorrian Linux - Software 1 05-09-2006 12:11 AM
Extremely poor SATA performance (Inappropriate ioctl for device) kyletriggs Linux - Hardware 7 02-14-2006 01:14 AM
Inappropriate ioctl for device(25) why1957 Linux - Networking 0 08-03-2003 04:45 AM
stty: standard input: Inappropriate ioctl for device fwalthard Linux - General 0 07-14-2003 02:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration