The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Inappropriate ioctl for device at contactme UNIX for Dummies Questions & Answers 0 03-26-2007 07:22 AM
Inappropriate ioctl for device, format error spoonman SUN Solaris 2 08-24-2006 09:01 AM
Inappropriate ioctl for device steelrose UNIX for Dummies Questions & Answers 4 08-23-2006 07:08 AM
Inappropriate ioctl for device spoonman UNIX for Dummies Questions & Answers 0 08-23-2006 06:39 AM
Inappropriate ioctl for device tojaiganesh Filesystems, Disks and Memory 4 03-17-2005 02:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-12-2005
RishiPahuja's Avatar
Registered User
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
Unhappy Inappropriate ioctl for device

Dear all,

Problem goes like this:

I have a shell script which when run manually runs perfectly.
When same script is executed through a job schdeduler I get an error as Inappropriate ioctl for device and the script fails.

This problems seems quite guiling to me.
Any clues are heartly welcomed.

Thanks
Rishi
Reply With Quote
Forum Sponsor
  #2  
Old 08-12-2005
Registered User
 

Join Date: Jul 2005
Posts: 33
does your script have any "read" statements? is there any reason why the script's stdin or stdout would need to be connected to a terminal?
Reply With Quote
  #3  
Old 08-12-2005
RishiPahuja's Avatar
Registered User
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
My script is not at all interactive and does not read from stdin.

yeah it do write to some /tmp directory while sorting the data.
And to my understanding this happens just when it tries to write to this mount.

Thanks for helping framing the problem more clear. hope this will help everyone to figure out the reason why it does happen?


Thanks
Rishi
Reply With Quote
  #4  
Old 08-12-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
You are doing something in your script directly or indirectly that does indeed require a tty, but it is not a read nor a write. Put some echo statement in your script "echo at point 1", "echo at point 2", etc until you see the statement that fails.
Reply With Quote
  #5  
Old 08-16-2005
RishiPahuja's Avatar
Registered User
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
Unhappy

Quote:
Originally Posted by Perderabo
You are doing something in your script directly or indirectly that does indeed require a tty, but it is not a read nor a write. Put some echo statement in your script "echo at point 1", "echo at point 2", etc until you see the statement that fails.
Thanks Perderabo for going over the question.
As the code exists in production and we cannot change code without lots of approvals.

Will like to elaborate the problem more clearly see if you can help.


We have a script say run_job.ksh which is executed from a scheduler.
This scripts calls a C executable, which itself invokes sort command.

The snippet of the code calling sort command is like this:

Code:
 sprintf(tmpSortFileName, "/tmp/temp%s", "tempIRBPAVAInputFile");
 
    /* Sort by carrier ID, company #, bill to RAO, statement date, BTN, ??? */
    sprintf(sortcmd,
             "sort -k 1.132,1.135 -k 1.118,1.119 -k 1.118,1.119 "\
                  "-k 1.112,1.114 -k 1.104,1.111 -k 1.142,1.151 "\
                  "-k 1.155,1.162 %s > %s", inputFileName, tmpSortFileName);
    system(sortcmd);
 
    if(errno)
    {
       fprintf(stderr,
              "Error sorting the input file %s...\nExiting...\n",
                inputFileName);
       exit(ERR);
    }
if same code we execute through a telnet session it succeeds while if we invoke the executable through scheduler we are thrown the error present in "if" condition i.e. Error sorting the input file

This is the sequence of error I receive in scheduler logs:

: Inappropriate ioctl for device
Error sorting the input file /tmp/tempIRBPAVAInputFile...
Exiting...


Any help will be highly appreciated.
Reply With Quote
  #6  
Old 08-16-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
That piece of c code is not the problem. Did you surround the this program with echo statements to be sure that it is causing the problem? If so, look further in the program for some tty specific operation.
Reply With Quote
  #7  
Old 08-16-2005
RishiPahuja's Avatar
Registered User
 

Join Date: Apr 2005
Location: Bangalore, India
Posts: 203
Unhappy

yes, as I told I am not in position to add echo statments but there do exists a echo statment and data echoed is perfectly visible in log.

After tht echo call only the C executable is invoker with appropiate arguments.

Why i am worried with this pieve of code specifically is we have two functioncalls sortTempInputFile and sortInputFile.

First call "sortInputFile" is always successfull while second call where only filename is different fails "sortTempInputFile"

before invoking the sort command we even check the error code.

complete code of function is:

Code:
void sortTempInputFile(char *inputFileName)
{
    char sortcmd         [1024] = "\0";
    char tmpSortFileName [1024] = "\0";
 
    iFileName[0] = '\0';
 
    if(errno)
    {
       perror(" ");
    }
 
    sprintf(tmpSortFileName, "/tmp/temp%s", "tempIRBPAVAInputFile");
 
    /* Sort by carrier ID, company #, bill to RAO, statement date, BTN, ??? */
    sprintf(sortcmd,
             "sort -k 1.132,1.135 -k 1.118,1.119 -k 1.118,1.119 "\
                  "-k 1.112,1.114 -k 1.104,1.111 -k 1.142,1.151 "\
                  "-k 1.155,1.162 %s > %s", inputFileName, tmpSortFileName);
    system(sortcmd);
 
    if(errno)
    {
       fprintf(stderr,
              "Error sorting the input file %s...\nExiting...\n",
                inputFileName);
       exit(ERR);
    }
 
    sprintf(sortcmd, "chmod 777 %s", tmpSortFileName);
    system(sortcmd);
 
    if(errno)
    {
       fprintf(stderr,"%s%s\n",
               "Error changing permissions for the temp input file ...",
               "Exiting...");
 
       exit(ERR);
    }
 
    sprintf(sortcmd, "mv -f %s %s", tmpSortFileName, inputFileName);
    system(sortcmd);
 
    if(errno)
    {
       fprintf(stderr,"Error moving the input file ...\nExiting...\n");
       exit(ERR);
    }
 
}
I greped for tty in all the scripts but could not find one...is there anyway we will be connecting to tty?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
inappropriate ioctl for device

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0