in reply to Re^2: a dumb socket question
in thread a dumb socket question

How about writing the result to the CLIENT socket? Sockets are bidirectional, and the client script is already connected to the server. I don't see any synchronization issues.
# server @results = <CMD>; print CLIENT @results; # client print SOCKET $cmd; @results = <SOCKET>;

Why do you have a separate server and client? Since they are running on the same machine, wouldn't it be easier to just have the client script do the ssh command? The only reason I can think of is that the server script is running as a different user with ssh privledges.

Replies are listed 'Best First'.
Re^4: a dumb socket question
by rhxk (Beadle) on Jul 15, 2004 at 18:46 UTC
    exactly. I would be running the server script which has the
    ssh key shared to the other machine(no passwd is prompted)
    I've implemented your suggestion in, but the client is not
    getting anything back. It is waiting on the
    @results = <SOCKET> indefinitely
    here's the modified client:
    if (socket(SOCKET, PF_UNIX, SOCK_STREAM, 0)) { connect(SOCKET, sockaddr_un($file)) || die "Could not connect: + $!"; print SOCKET $cmd; @results = <SOCKET>; print @results;
    here's the modified server:
    socket(SERVER, PF_UNIX, SOCK_STREAM, 0) || die "Could not create socke +t: $!"; unlink("$file"); bind(SERVER, $addr) || die "Could not bind: $!"; listen(SERVER,SOMAXCONN) || die "Could not listen: $!"; while (accept(CLIENT,SERVER) || die "could not accept: $!") { $cmd = <CLIENT>; if ($cmd) { $cmdd = "ssh2 rob\@machine_b $cmd"; + open(CMD, "$cmdd |"); @results = <CMD>; close(CMD); + print CLIENT @results; } }
    somehow the print CLIENT @results is not
    actually returning the results....guess i have to do more tests