X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=plink.c;h=80c5b6aed9aff754b0011a813b7033890d365ccc;hb=aa5f38e53c5ce7888b14e65a768ae420c83bf2e1;hp=77724a5b519b720e9bd4435f70c55a439452fc09;hpb=f08de20a1e9ea12f207622bd381d769e2151d584;p=PuTTY.git diff --git a/plink.c b/plink.c index 77724a5b..80c5b6ae 100644 --- a/plink.c +++ b/plink.c @@ -339,6 +339,7 @@ static void usage(void) printf("PuTTY Link: command-line connection utility\n"); printf("%s\n", ver); printf("Usage: plink [options] [user@]host [command]\n"); + printf(" (\"host\" can also be a PuTTY saved session name)\n"); printf("Options:\n"); printf(" -v show verbose messages\n"); printf(" -ssh force use of ssh protocol\n"); @@ -786,10 +787,12 @@ int main(int argc, char **argv) } else if (n == 1) { reading = 0; noise_ultralight(idata.len); - if (idata.len > 0) { - back->send(idata.buffer, idata.len); - } else { - back->special(TS_EOF); + if (connopen && back->socket() != NULL) { + if (idata.len > 0) { + back->send(idata.buffer, idata.len); + } else { + back->special(TS_EOF); + } } } else if (n == 2) { odata.busy = 0; @@ -800,8 +803,10 @@ int main(int argc, char **argv) bufchain_consume(&stdout_data, odata.lenwritten); if (bufchain_size(&stdout_data) > 0) try_output(0); - back->unthrottle(bufchain_size(&stdout_data) + - bufchain_size(&stderr_data)); + if (connopen && back->socket() != NULL) { + back->unthrottle(bufchain_size(&stdout_data) + + bufchain_size(&stderr_data)); + } } else if (n == 3) { edata.busy = 0; if (!edata.writeret) { @@ -811,14 +816,18 @@ int main(int argc, char **argv) bufchain_consume(&stderr_data, edata.lenwritten); if (bufchain_size(&stderr_data) > 0) try_output(1); - back->unthrottle(bufchain_size(&stdout_data) + - bufchain_size(&stderr_data)); + if (connopen && back->socket() != NULL) { + back->unthrottle(bufchain_size(&stdout_data) + + bufchain_size(&stderr_data)); + } } if (!reading && back->sendbuffer() < MAX_STDIN_BACKLOG) { SetEvent(idata.eventback); reading = 1; } - if (!connopen || back->socket() == NULL) + if ((!connopen || back->socket() == NULL) && + bufchain_size(&stdout_data) == 0 && + bufchain_size(&stderr_data) == 0) break; /* we closed the connection */ } WSACleanup();