Hi list,
i've been bashing my head on this one for a long time so i'd like to know if someone could give me an hint on it.
I'm writing a script to control how i use udpcast to install my machines. My problem is that when i try to use "read" (bash builtin), right after udp-sender complete his transfer (Transfer complete. Disconnecting ...), "read" cannot read from the keyboard and i'm having this error :
read: read error: 0: Resource temporarily unavailable
I even try to write my script in perl but "chomp" fail at the same place...
I'm pretty sure that it is a File Descriptor problem but don't know how to solve it. I think the relevant udpcast code is in console.c but i'm not a C programmer so i don't understand very well how things or going out in this file.
Thanks a lot!
Tony
DeadManMoving wrote:
Hi list,
i've been bashing my head on this one for a long time so i'd like to know if someone could give me an hint on it.
I'm writing a script to control how i use udpcast to install my machines. My problem is that when i try to use "read" (bash builtin), right after udp-sender complete his transfer (Transfer complete. Disconnecting ...), "read" cannot read from the keyboard and i'm having this error :
read: read error: 0: Resource temporarily unavailable
I even try to write my script in perl but "chomp" fail at the same place...
I'm pretty sure that it is a File Descriptor problem but don't know how to solve it. I think the relevant udpcast code is in console.c but i'm not a C programmer so i don't understand very well how things or going out in this file.
Thanks a lot!
Tony
I just tried this, both with an udp-sender running on the host system, and in the embedded system. In both cases, it worked as expected. In order to check what happens if it can't restore the console to a working state, I also tried, in both cases (embedded and server), to kill -9 udp-sender while it was waiting for the start signal. It did even work in that case (although the user's input was not echo'ed by the tty in that case, the shell still got it all right).
Here are the scripts I used for testing:
On server:
#!/bin/sh
udp-sender -f /bin/ls echo Shell read read a echo Got $a
In the embedded system (installed as a post script):
#!/bin/sh
read a echo Got $a
On a third machine, I had an udp-receiver running for the test.
In all 4 cases, it worked (embedded/success, embedded/kill-9, server/success, server/kill-9)
Could you supply details of your script and environment where it fails?
Thanks,
Alain
On Wed, 2006-03-08 at 10:36 +0100, Alain Knaff wrote:
Thanks a lot!
Tony
I just tried this, both with an udp-sender running on the host system, and in the embedded system. In both cases, it worked as expected. In order to check what happens if it can't restore the console to a working state, I also tried, in both cases (embedded and server), to kill -9 udp-sender while it was waiting for the start signal. It did even work in that case (although the user's input was not echo'ed by the tty in that case, the shell still got it all right).
Here are the scripts I used for testing:
On server:
#!/bin/sh
udp-sender -f /bin/ls echo Shell read read a echo Got $a
In the embedded system (installed as a post script):
#!/bin/sh
read a echo Got $a
On a third machine, I had an udp-receiver running for the test.
In all 4 cases, it worked (embedded/success, embedded/kill-9, server/success, server/kill-9)
Could you supply details of your script and environment where it fails?
Thanks,
Alain
Hi Alain,
thanks a lot for your time and answer; this is highly appreciated.
The first thing that catch my attention is that i use a pipe instead of the -f switch.
Here is the relevant portion of my script :
case ${yes_or_no} in
Y|y|yes|Yes|YES) start_srv alive=$( expr $alive + $dead ) echo echo echo for host in ${ghost_host[*]}; do echo "Starting udp-receiver on host $host." sleep 1 prep_host $host done echo echo sleep 5 echo "All hosts ready, starting udp-sender on $SHORT_HOST." sleep 5 echo echo cd ${IMG_DIR}
/usr/local/sbin/udp-sender --nokbd --min-clients $alive --interface \ eth0 --pipe "tar cfp - ./"
sleep 15 clear echo echo echo "Transfer finished," echo echo " ***YOU SHOULD WAIT UNTIL" echo "ALL CLIENT(S) HAVE COMPLETED THERE POST-CONFIG***." echo echo "Press return when done." echo
### THIS IS WHERE READ FAIL! read junk ### echo "Returning to main menu." unset host2ghost host_count sleep 5 ;;
Here is the relevant portion of an strace debug output :
write(1, "Transfer finished,\n", 19) = 19 write(1, "\n", 1) = 1 write(1, " ***YOU SHOULD WAIT UN"..., 36) = 36 write(1, "ALL CLIENT(S) HAVE COMPLETED THE"..., 51) = 51 write(1, "\n", 1) = 1 write(1, "Press return when done.\n", 24) = 24 write(1, "\n", 1) = 1 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 read(0, 0x80e0a60, 128) = -1 EAGAIN (Resource temporarily unavailable) open("/usr/share/locale/locale.alias", O_RDONLY) = 3
does'nt seem to tell that much...
Once again, thanks a lot!!!
Tony