PuTTY doesn't know when a remote command is waiting for input. As far as the terminal (or the SSH client) is concerned, input can always be sent. (Even trying to guess based on shown text is futile since many progress displays are indistinguishable to a computer from input prompts.)
Given your requirements, the only option I can think of is a LD_PRELOAD
library that prints a bell whenever any program tries to read from a tty device. Something like:
#define _GNU_SOURCE
#include <dlfcn.h>
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count) {
static ssize_t (*real_read)(int fd, void *buf, size_t count);
if (isatty(fd))
write(fd, "\a", 1);
if (!real_read)
real_read = dlsym(RTLD_NEXT, "read");
return real_read(fd, buf, count);
}
(Well, it doesn't work for any statically-linked binary, but close enough.)
Then again, if a command waits for input, then it is by definition not done, so the requirements are somewhat contradictory.
i think you have written kind of a proxy function for read command. the command is a build script actually and when i run it, it asks for sudo permission in between when i have to enter the password. also every time a run a command i have to make sure i end it with
tput bel
otherwise i wont hear any bell. so there is no generic solution for putty? – wolfram77 – 2016-06-06T11:30:16.533The
read()
libc function has nothing to do with theread
shell command. As for sudo,export SUDO_PROMPT=$'\aEnter sudo password: '
– user1686 – 2016-06-06T11:47:54.570my bad, i mean
read()
libc function only. But i am surprised that it is not possible. (many progress displays are indistinguishable to a computer from input prompts). Isnt it true that a program waiting on input would be waiting by a read from stdin in its main thread. Linux should be able to know that the program is indeed waiting for input, and not processing something.. If so is possible it should also be possible to pass on this information to PuTTY. – wolfram77 – 2016-06-06T15:30:03.270Maybe all this is getting so complicated, and i should stick to
tput
. But i asked this question guessing someone might have an easier way. Thanks. – wolfram77 – 2016-06-06T15:30:43.067