Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using an AutoHotkey macro to run some shell commands, i.e.

^`::
SendInput set c=".cshrc-acheong"{ENTER}
SendInput set v=".vimrc-acheong"{ENTER}
SendInput foreach d ( /home/acheong /home/tcama /userhome/andrew.cheong ){ENTER}
SendInput if ( -e $d/$c ) source $d/$c{ENTER}
SendInput if ( -e $d/$v ) alias vim "vim -N -u $d/$v"{ENTER}
SendInput end{ENTER}
return

If you're not familiar with AutoHotkey, no problem—it's the same as pasting several lines of shell commands at once—and many of us have seen how the command prompt appears "asynchronously" as each line executes:

enter image description here

Is there a command or trick to hiding (perhaps blocking) stdin and then executing the input without displaying it (or its outputs)? Sort of like typing passwords.


Please be sparing of judgments regarding the above :-( To preemptively disclaim some things:

  1. I don't use csh by choice; yes, I've read the Top 10.

  2. I work with hundreds of servers that don't all mount the same network share for /home—that's why I'm using rsync to push a "master" .cshrc and .vimrc to a location per distinct network share, so that the above keyboard macro will find and load whichever is found, wherever I am.


Update

I tried adding stty -echo, i.e.

^`::
SendInput stty -echo{ENTER}
SendInput set c=".cshrc-acheong"{ENTER}
SendInput set v=".vimrc-acheong"{ENTER}
SendInput foreach d ( /home/acheong /home/tcama /userhome/andrew.cheong ){ENTER}
SendInput if ( -e $d/$c ) source $d/$c{ENTER}
SendInput if ( -e $d/$v ) alias vim "vim -N -u $d/$v"{ENTER}
SendInput end{ENTER}
SendInput stty echo{ENTER}
return

However the prompts continue to appear:

enter image description here

(I thought about unsetting $prompt but I'm reluctant as one of the things my .cshrc does is precisely to replace $prompt.)

share|improve this question
    
Just an idea: put small wait statements between SendInput commands so that the shell can react before it gets new input. –  jofel Apr 11 at 18:23
    
@jofel - AHK provides such a command, Sleep, but in this case I'd like to hide what's happening regardless, even if it formats nicely. Thanks for the tip though. –  Andrew Cheong Apr 11 at 18:25

3 Answers 3

I'm not familiar with AutoHotKey, so if you can't find any solution there, read on.

POSIX specifies the read command, which allows taking a line of input while stifling the terminal echo (that's what you see when you type) with -s. This is also a bash built-in, but you might check your system to see if it is present as a standalone.

Otherwise, looking here, you can accomplish the the same thing using stty (another standalone) with csh:

stty -echo # turn echo off
# do your input
stty echo # turn echo back on
share|improve this answer
    
AutoHotKey is a Windows hack-language. You don't want to be any more familiar with it than that, I promise you. –  mikeserv Apr 11 at 18:28

You can get pretty close to what you want by using the alternate screen buffer.
Most (all?) terminal emulators have 2 screen buffers that you can switch between. So you switch to the alternate screen buffer, run your commands, and then switch back to the main one.

Just run the following before your commands:

tput smcup

And at the end, run

tput rmcup

However this will still show the tput smcup command on the screen.
The only way I can think of hiding the command is to add a key binding to it (like ESC+t). I know zsh can do this, but I do not know about csh.


If you do not have the tput command, you can echo out the raw escape codes.
For putty, this would be:

echo -e '\e[?47h'

and

echo -e '\e[2J\e[?47l'
share|improve this answer

You should mkfifo a bidirectional |pipe between the two machines and write to it instead of relying on pasting into a putty terminal. But if you must use putty, then you should turn off its flow control in the settings and use raw mode - stty raw on the host side and find the raw terminal option in putty's settings.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.