For Programmers: Free Programming Magazines  


Home > Archive > AWK > November 2005 > system call hangs after getline









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author system call hangs after getline
caribou

2005-11-28, 7:55 am

I've got an awk program which reads a configuration file, generates
shell commands from this file and then executes them. All this is done
with an interactive interface.

Ex :

while (choice !~ /^[qQ]$/)
{
uiPrintPrompt()
getline choice

if ( choice ~ /^[lL]$/){
cmd = getListCommand(conffile)
exitStatus = system(cmd)
if (exitStatus == 0){
printf("%s\n ", OK)
} else {
printf("%s\n ", ERROR)
}
} else if ( choice ~ /^[ru]$/){
# remote cvs update
cmd=getRemoteUpdateCommand(conffile)
exitStatus = system(cmd)
if (exitStatus == 0){
printf("%s\n ", OK)
} else {
printf("%s\n ", ERROR)
}
.....
}
}

One of the command is a remote command using ssh

ex : ssh -l my_user remote_machine 'cd my_dir; cvs update'

This is the only command which fails (all local commands are OK)'

This command runs successfully from shell.
This command runs successfully in a simple awk program :

BEGIN {
command="ssh -l my_user remote_machine 'cd my_dir; cvs update'"
exitStatus = system(command)
if (exitStatus == 0){
printf("OK\n ")
} else {
printf("ERROR\n ")
}
}

It exits and prints OK.

The command hangs after a getline (so it hangs in my program which is
'while getline loop' )

ex :

BEGIN {
command="ssh -l my_user remote_machine 'cd my_dir; cvs update'"
getline dummy
exitStatus = system(command)
if (exitStatus == 0){
printf("OK\n ")
} else {
printf("ERROR\n ")
}
}

After typing text then RETURN, commands starts to run but never
ends.....
We can see the command has started because there is a start of output :
cvs server: WARNING: global `-l' option ignored.
(this warning is also printed when command goes OK in the shell)


Has some any idea of the reasons ???????????????

Kenny McCormack

2005-11-28, 7:55 am

In article <1133180483.027997.63410@g44g2000cwa.googlegroups.com>,
caribou <v.cariven@gmail.com> wrote:
>I've got an awk program which reads a configuration file, generates
>shell commands from this file and then executes them. All this is done
>with an interactive interface.


Off topic in c.l.a., but I'm guessing you probably need to do "man ssh" and
look for the option that tells ssh not to read from stdin.

caribou

2005-11-29, 3:55 am

Sorry, i'm a newbee at newsgroup. But thanks for your answer. (The
option is -n)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com