LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   executing commands in invisible mode (https://www.linuxquestions.org/questions/linux-newbie-8/executing-commands-in-invisible-mode-801690/)

dinakumar12 04-13-2010 02:17 AM

executing commands in invisible mode
 
Hi,

i just want to know whether we can execute the commands in invisible mode in linux. i.e.the command we typed must be executed but should not be visible.is it possible.

if not,then how the password we are typing is not visible in linux,while creating or entering password for users.

thanks in advance,
Dinesh.

David the H. 04-13-2010 05:19 AM

For what purpose do you want to have a non-echoing command line? It seems to me like it would be rather awkward to use. And while there are obviously ways to keep text from being echoed to output, I don't think it's something that can be enabled generally in most shells. I could be wrong though.

But if you really want a way to launch a command without it being visible, one quick and dirty solution I thought of is a simple function using the "-s" silent option of bash's "read" built-in.

Code:

function scom() {
  read -s COMMAND
  eval $COMMAND
}

Once this function is enabled, just run "scom" (silent command), and it will give you a blank line that you can type into without having it echoed. It will then attempt to execute whatever you put in that line.

Note though that there are limitations to this. Few of the regular bash features will be available. There's no tab-completion or command history available, for example. Notice also that this won't affect the output of the commands either. Any cli output or error messages will still appear usual, although you could add "&>/dev/null" to the end of the launching line to dispose of that as well.

Finally, you can add the function name to your HISTIGNORE environment variable so that it won't be stored in the command history, if you want to hide even that.

centosboy 04-13-2010 06:45 AM

Quote:

Originally Posted by dinakumar12 (Post 3933732)
Hi,

i just want to know whether we can execute the commands in invisible mode in linux. i.e.the command we typed must be executed but should not be visible.is it possible.

if not,then how the password we are typing is not visible in linux,while creating or entering password for users.

thanks in advance,
Dinesh.

so you want the command executed, but not seen on the command line?
have you tried

Code:

stty -echo

Aquarius_Girl 04-13-2010 06:49 AM

centosboy

Thanks !! That worked great !

Now kindly tell me how to revert it back to normal ????

unSpawn 04-13-2010 11:14 AM

Moved: This thread is more suitable right here and was moved accordingly to help your thread/question get the exposure it deserves.

MTK358 04-13-2010 11:18 AM

I don't know if this helps:

Code:

command &> /dev/null &
The output of the command (both stdout and stderr) is sent to /dev/null so it isn't printed out, and it is put in the background so you can keep using the shell.

gumaheru 04-13-2010 11:28 AM

The two ways to do this were stated above. First option is to send all standard output and error to /dev/null. The second would be to disable character echo in the shell. This is done by running "stty -echo". Both of these were stated above by MTK358 and centosboy.

devnull10 04-13-2010 12:18 PM

Quote:

Originally Posted by anishakaul (Post 3933947)
centosboy

Thanks !! That worked great !

Now kindly tell me how to revert it back to normal ????

stty echo

dinakumar12 04-14-2010 11:15 PM

Hi,

Thank you very much, it works ,but is reboot the only option to recover from this mode or we have any other special command for this.

thanks&advance,
Dinesh.

Tinkster 04-14-2010 11:44 PM

How many of the responses above did you actually READ?

Aquarius_Girl 04-14-2010 11:48 PM

devnull10

Thanks for the response :)

dinakumar12 04-15-2010 12:24 AM

Hi,

Thank you very much.yes this looks great.

kingston 04-15-2010 12:27 AM

this is cooooooooooooollll...i liked this very much....
thanks to centosboy and devnull


All times are GMT -5. The time now is 02:27 AM.