"inappropriate ioctl for device"

Viewed 328062

I have a Perl script running in an AIX box.

The script tries to open a file from a certain directory and it fails to read the file because file has no read permission, but I get a different error saying inappropriate ioctl for device.

Shouldn't it say something like no read permissions for file or something similar?

What does this inappropriate ioctl for device message mean?

How can I fix it?

EDIT: This is what I found when I did strace.

open("/local/logs/xxx/xxxxServer.log", O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE, 
    0666) = 4 _llseek(4, 0, [77146], SEEK_END) = 0
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbffc14f8) = -1 ENOTTY 
    (Inappropriate ioctl for  device)
11 Answers

I got the error Can't open file for reading. Inappropriate ioctl for device recently when I migrated an old UB2K forum with a DBM file-based database to a new host. Apparently there are multiple, incompatible implementations of DBM. I had a backup of the database, so I was able to load that, but it seems there are other options e.g. moving a perl script/dbm to a new server, and shifting out of dbm?.

I also get this error "inappropriate ioctl for device" when try to fetch file stat. It was first time when I got a chance to work on perl script.

my $mtime = (stat("/home/ec2-user/sample/test/status.xml"))[9]

Above code snippet was throwing error. Perl script was written in version 5.12 on Windows, and I have to run it on amazon linux having perl 5.15.

In my case error was because of Array index out of bond ( In java language sense).

When I modified code my $var = (stat("/home/ec2-user/sample/test/status.xml"))[0][9]; error gone and I get correct value.

Of course, it is too late to answer, but I am posting my finding so that it can be helpful for developer community. If some perl expert can verify this, it will be great..

Related