* fgets and ssh
@ 2007-04-11 12:17 Benoît Rouits
2007-04-11 14:01 ` Stephen Kratzer
0 siblings, 1 reply; 3+ messages in thread
From: Benoît Rouits @ 2007-04-11 12:17 UTC (permalink / raw)
To: linux-c-programming
hello,
in a minimal shell tutorial written in C, i have a read_line function
that does:
char* read_line()
{
char* line=NULL;
line=(char*)malloc(512);
line=fgets(line,512,stdin);
return line;
}
then i parse this line to build a correct "argv" to pass to execvp()
everything works well when i use ssh interactively.
The problem i encounter is when i pass a command to ssh into this shell:
ssh -v guest@localhost ls
[...]
guest@localhost's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = fr_FR.utf8
debug1: Sending command: ls
( here the shell waits )
the shell still waits for ls and i have to retype intaractively "ls" to
get the correct result:
ls
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Desktop
Examples
debug1: channel 0: free: client-session, nchannels 1
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 61.4 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 9
any explanation would be greatly appreciated.
+ben
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fgets and ssh
2007-04-11 12:17 fgets and ssh Benoît Rouits
@ 2007-04-11 14:01 ` Stephen Kratzer
2007-04-11 15:23 ` fgets and ssh [resolved] Benoît Rouits
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Kratzer @ 2007-04-11 14:01 UTC (permalink / raw)
To: Benoît Rouits; +Cc: linux-c-programming
On Wednesday 11 April 2007 08:17, Benoît Rouits wrote:
> hello,
> in a minimal shell tutorial written in C, i have a read_line function
> that does:
>
> char* read_line()
> {
> char* line=NULL;
> line=(char*)malloc(512);
> line=fgets(line,512,stdin);
> return line;
> }
>
> then i parse this line to build a correct "argv" to pass to execvp()
> everything works well when i use ssh interactively.
>
> The problem i encounter is when i pass a command to ssh into this shell:
>
> ssh -v guest@localhost ls
> [...]
> guest@localhost's password:
> debug1: Authentication succeeded (password).
> debug1: channel 0: new [client-session]
> debug1: Entering interactive session.
> debug1: Sending environment.
> debug1: Sending env LANG = fr_FR.utf8
> debug1: Sending command: ls
> ( here the shell waits )
>
> the shell still waits for ls and i have to retype intaractively "ls" to
> get the correct result:
>
> ls
> debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
> Desktop
> Examples
> debug1: channel 0: free: client-session, nchannels 1
> debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 61.4 seconds
> debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
> debug1: Exit status 9
>
> any explanation would be greatly appreciated.
>
> +ben
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
When ssh is executed in the form 'ssh user@host command', the login shell of
the user will be called like so: 'shell -c command'. That is, commands are
not fed into the shell interactively on stdin, they're provided as arguments
following a -c option flag.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fgets and ssh [resolved]
2007-04-11 14:01 ` Stephen Kratzer
@ 2007-04-11 15:23 ` Benoît Rouits
0 siblings, 0 replies; 3+ messages in thread
From: Benoît Rouits @ 2007-04-11 15:23 UTC (permalink / raw)
To: kratzers; +Cc: linux-c-programming
Thank you very much Stephen, now it works with "-c command"
and so "scp" can also work.
Le mercredi 11 avril 2007 à 10:01 -0400, Stephen Kratzer a écrit :
> When ssh is executed in the form 'ssh user@host command', the login
> shell of
> the user will be called like so: 'shell -c command'. That is, commands
> are
> not fed into the shell interactively on stdin, they're provided as
> arguments
> following a -c option flag.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-11 15:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-11 12:17 fgets and ssh Benoît Rouits
2007-04-11 14:01 ` Stephen Kratzer
2007-04-11 15:23 ` fgets and ssh [resolved] Benoît Rouits
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).