LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-13-2010, 03:17 AM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
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.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-13-2010, 06:19 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
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.
 
Old 04-13-2010, 07:45 AM   #3
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by dinakumar12 View Post
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
 
2 members found this post helpful.
Old 04-13-2010, 07:49 AM   #4
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,674
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
centosboy

Thanks !! That worked great !

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

Last edited by TheIndependentAquarius; 04-13-2010 at 07:57 AM.
 
Old 04-13-2010, 12:14 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Moved: This thread is more suitable right here and was moved accordingly to help your thread/question get the exposure it deserves.
 
Old 04-13-2010, 12:18 PM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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.
 
Old 04-13-2010, 12:28 PM   #7
gumaheru
LQ Newbie
 
Registered: Nov 2009
Posts: 20

Rep: Reputation: 0
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.
 
Old 04-13-2010, 01:18 PM   #8
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 548

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by anishakaul View Post
centosboy

Thanks !! That worked great !

Now kindly tell me how to revert it back to normal ????
stty echo
 
1 members found this post helpful.
Old 04-15-2010, 12:15 AM   #9
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
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.
 
0 members found this post helpful.
Old 04-15-2010, 12:44 AM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
How many of the responses above did you actually READ?
 
Old 04-15-2010, 12:48 AM   #11
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,674
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
devnull10

Thanks for the response
 
Old 04-15-2010, 01:24 AM   #12
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Hi,

Thank you very much.yes this looks great.
 
Old 04-15-2010, 01:27 AM   #13
kingston
Member
 
Registered: Mar 2008
Location: Bengaluru, India
Distribution: RHEL 5.5, Solaris 5.10
Posts: 215
Blog Entries: 1

Rep: Reputation: 21
this is cooooooooooooollll...i liked this very much....
thanks to centosboy and devnull
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How commands are executing ? gsiva Linux - Server 1 07-21-2009 09:48 AM
Executing commands at a specified time Siva4Linux Linux - Wireless Networking 7 02-21-2007 06:49 AM
executing shell commands in c++ true_atlantis Programming 2 10-01-2004 05:53 PM
Executing commands in Konsole... meteotrade Linux - General 5 10-20-2003 07:34 PM
Executing commands on startup viciousfish Linux - General 5 06-28-2002 03:15 PM


All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration