Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ssh hanging

10 views
Skip to first unread message

mark.b...@thales-is.com

unread,
Jun 6, 2012, 6:48:15 AM6/6/12
to
Hello,
We have a program that ssh's to another system to run scp copying files back to the original system. If there are no files present on the remote system, the ssh occasionally hangs, and we don't know why!

e.g. Program running on System A has C code:

sprintf (cmd, "ssh -n B 'scp -p /srcdir/* A:/destdir'");
status = system(cmd);

If /srcdir is empty, the ssh occasionally hangs, although running the ssh command manually does return with error:
/srcdir/*: No such file or directory

Any ideas?

mark.b...@thales-is.com

unread,
Jun 6, 2012, 6:59:16 AM6/6/12
to
On Wednesday, June 6, 2012 11:48:15 AM UTC+1, I wrote:
> the ssh occasionally hangs, and we don't know why!

By the way, we're using Red Hat Linux, I think 4.5

Richard Kettlewell

unread,
Jun 6, 2012, 7:07:55 AM6/6/12
to
mark.b...@thales-is.com writes:

> We have a program that ssh's to another system to run scp copying
> files back to the original system. If there are no files present on
> the remote system, the ssh occasionally hangs, and we don't know why!
>
> e.g. Program running on System A has C code:
>
> sprintf (cmd, "ssh -n B 'scp -p /srcdir/* A:/destdir'");
> status = system(cmd);

Any reason you're not using:
"scp 'B:/srcdir/*' /destdir"
?

> If /srcdir is empty, the ssh occasionally hangs, although running the
> ssh command manually does return with error:
> /srcdir/*: No such file or directory
>
> Any ideas?

Might be worth applying strace to the hung process to see if you can get
some idea what it's stuck on.

--
http://www.greenend.org.uk/rjk/

mark.b...@thales-is.com

unread,
Jun 6, 2012, 10:05:27 AM6/6/12
to
> Any reason you're not using:
> "scp 'B:/srcdir/*' /destdir"

Good point. It's code I inherited, and has an alternative code-path doing more than just scp within the ssh, but I think I might change it at you suggest.
I suspect the problem in the current code may relate to the error message going to stderr, so redirecting stderr to /dev/null might also help.

Adam Wysocki

unread,
Jun 7, 2012, 7:11:40 AM6/7/12
to
mark.b...@thales-is.com wrote:

> sprintf (cmd, "ssh -n B 'scp -p /srcdir/* A:/destdir'");
> status = system(cmd);

Try ssh -v.

--
Gof
0 new messages