- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Generated or received a file descriptor number...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2011 12:56 PM
11-21-2011 12:56 PM
Generated or received a file descriptor number that is not valid
Hi there.
I'm running a shell script that is calling another one.
So it looks like this:
runer.sh
exec 4<&0
while read Filer User Password Sysdba; do
case $Filer in
*.sh)
exec 5<&0
exec 0<&4
.$Filer
if test $? -ne 0;
then echo ERROR: .$Filer encountered an error ` 2>&1 | tee -a $LOG_DIRECTORY
echo 2>&1 | tee -a $LOG_DIRECTORY
fi;
exec 0<&5;;
;;
esac
done < `basename $list_file`;
FileinFiler.sh
echo 'Do you really wish to remove the user (y/n)?' 2>&1 | tee -a $LOG_DIRECTORY
exec 5<&0
exec 0<&4
read continue
exec 0<&5
So line 3 in FileinFiler.sh (exec 0<&4) is causing the above error.
When I run this in Linux with LSOF I see that the file descriptor is recognized.
So I guees that in HP-UX, the filedescriptor 4 has been lost for the switch of content when calling the second shell (I do not know how to install LSFOF in HP-UX...looking for that info now).
So my question is: how do I fix this one? I think the intent here is to get the value of the answer in the continue variable and write it to a file.
Thanks for any help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2011 01:19 PM - edited 11-21-2011 01:22 PM
11-21-2011 01:19 PM - edited 11-21-2011 01:22 PM
Re: Generated or received a file descriptor number that is not valid
>.$Filer
Is there a space after the period?
>echo ERROR: .$Filer encountered an error ` 2>&1 | tee -a $LOG_DIRECTORY
>echo 2>&1 | tee -a $LOG_DIRECTORY
That (`) is unbalanced. Also you don't need to use "2>&1" here. And you might as well combine the two echoes:
echo "ERROR: .$Filer encountered an error\n" | tee -a $LOG_DIRECTORY
>echo 'Do you really wish to remove the user (y/n)?' 2>&1 | tee -a $LOG_DIRECTORY
exec 5<&0
exec 0<&4
read continue
Why bother with this exec fiddling if this is already done in runer.sh before FileinFiler.sh is called?
>I guess that in HP-UX, the filedescriptor 4 has been lost for the switch of content when calling the second shell (I do not know how to install lsof in HP-UX.).
You want tusc instead to trace the system calls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2011 01:37 PM
11-21-2011 01:37 PM
Re: Generated or received a file descriptor number that is not valid
Yes the unbalanced ' was a copy and paste mistake.
No space before the period.
I think the intent was to grab th response and add it to the log file somehow.
Your suggestions are fine, but they do not cause the error that I'm experiencing.
Not sure what tusc is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2011 04:05 PM - edited 11-21-2011 10:27 PM
11-21-2011 04:05 PM - edited 11-21-2011 10:27 PM
Re: Generated or received a file descriptor number that is not valid
>No space before the period.
I was asking about after. If you source that script, it doesn't have that FD error.
>Not sure what tusc is.
As I said, this is the tool you need. It traces system calls.
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/tusc-8.1/
tusc shows that a real shell doing I/O redirection with exec command, calls: fcntl(FD, F_SETFD, FD_CLOEXEC)
This doesn't happen if you source the script.
But since the file you source redoes the redirection, FD 5 is destroyed in the first script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2011 06:56 AM
11-22-2011 06:56 AM
Re: Generated or received a file descriptor number that is not valid
Thanks for your quick answers...but I do not think I follow you with the source thing.
My experience with HP-UX is a total of about 2 days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2011 01:40 PM
11-22-2011 01:40 PM
Re: Generated or received a file descriptor number that is not valid
>but I do not think I follow you with the source thing.
Do you have a space after that period? That's called sourcing in a real shell.
When you source a script, you don't do an exec, so the redirected files remain open.
And then you'll need to remove the exec(s) in the FileinFiler.sh.