Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My Script throws the error read error: 0: Resource temporarily unavailable the second time user input ( Unix Username ) is expected.

I suspect this has something to do with the first background process (linux_fetch &) going wrong.

How do I work around this so that the user prompt ( Unix Username ) post the background process does not get affected.

Here is short snippet of the script.

if [ -r $linux_host_list ]
then
    echo
    read -p 'Linux Username:' LUSERNAME
    read -p 'Linux Password:' LPASS
    linux_fetch &
    clear screen
else
    echo "No Linux Servers found"
fi

if [ -r $unix_host_list ]
then
    echo
    read -p 'Unix Username:' UNIXUNAME
    read -p 'Unix Password:' UPASS
    unix_fetch &
    clear screen
else
    echo "No Unix Servers found."
fi
share|improve this question

2 Answers 2

I'll bet that the unix_fetch process is closing or doing something else insane with stdin. Try running unix_fetch with </dev/null, so that it's stdin is redirected away to somewhere it can't do any damage.

share|improve this answer
    
I still keep getting the error once in while,especially if I try to provide user input fast –  Sharjeel Sayed Aug 20 '09 at 7:38
1  
I just tried < /dev/null on a BASH script which was having the same problem, and it worked beautifully! Thanks! Can you tell me what the difference is between myscript.sh < /dev/null and myscript.sh > /dev/null? –  Taeram Nov 23 '09 at 17:14
1  
< /dev/null sets stdin (where the process reads from) to null, while > /dev/null sets stdout (where the process writes to) to null. –  womble Nov 23 '09 at 18:30
up vote 0 down vote accepted

A simple redirection of error to /dev/null did the trick for me.

linux_fetch 2> /dev/null &
unix_fetch 2> /dev/null &
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.