General :: Clear Stdin Before Reading?

Apr 28, 2011

I have the following bash script:

#do some time consuming task here read -p "Give me some input: " input

Now as you might've guessed, if users press some random keys during the "time consuming task," they're read into input as well. how do I clear stdin (or at least ignore it) before I issue the read command?

View 1 Replies


ADVERTISEMENT

General :: Why Is Reading A FILE Faster Than Reading A VARIABLE?

May 4, 2011

I don't understand the results of a simple performance test I ran using two basic scripts (running on a high end server):

perfVar.zsh :

#!/bin/zsh -f
MYVAR=`cat $1`
for i in {1..10}

[code]...

Performance test result:

> time ./perfVar.zsh BigTextFile > /dev/null
./perfVar.zsh FE > /dev/null 6.86s user 0.32s system 100% cpu 7.177 total
> time ./perfCat.zsh BigTextFile > /dev/null
./perfCat.zsh FE > /dev/null 0.01s user 0.10s system 91% cpu 0.118 total

I would have thought that accessing a VARIABLE was way faster than reading a FILE on the file system... Why this result ?Is there a way to optimize the perfCat.zsh script by reducing the number of accesses to the file system ?

View 3 Replies View Related

General :: How To Echo Redirected Stdin

Sep 26, 2010

I execute an application from a script file and redirect stdin to it from here-doc like this:

my_cli << HERE_DOC
enable
configure
10
exit
exit
HERE_DOC

This works as expected, but I don't see neither the input nor the app output. The application is an interactive prompt written in C. When I interact manually with it, I see the prompt itself and responses to my input, but when I execute the aforementioned script I see nothing. I would like it to print the input and the output as if a real user was typing. Do you know how to achieve that?

View 3 Replies View Related

General :: Writing To The STDIN Of A Shell?

Jul 28, 2010

I am trying to write input to a shell and get the shell to parse the input that I am writing to it as if a user was typing in commands.

Thus far I have tried echoing some text into the shell's FD for STDIN in /proc/<pid>/fd Whilst this displays the text that I echo, the shell that I am writing to never tries to execute the command that I pass to STDIN. What is the difference between a shell taking STDIN from the user and data written to STDIN by another process e.g. echo ? It appears I am missing something fundamental.

View 5 Replies View Related

General :: Redirect Stdin And Stderr To Another Terminal?

Jun 28, 2010

Is it possible to redirect stdout and stderr from one terminal say /dev/pts/2 to another /dev/pts/3?

I tried the following:

Code:
/dev/pts/2 2>&1 /dev/pts/3&

Then when I run a command the process stops.

View 4 Replies View Related

Ubuntu Networking :: Broadcom On 2.6.34 - Reinstall Error Code: Reading Package Lists ... Done Building Dependency Tree Reading State Information

May 20, 2010

i installed kernel 2.6.34 to fix my lid closing issue, and that went great. but now when i go to reinstall my broadcom i get this error. Code: Reading package lists... Done Building dependency tree Reading state information... Done bcmwl-kernel-source is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. 1 not fully installed or removed. After this operation, 0B of additional disk space will be used. Setting up bcmwl-kernel-source (5.60.48.36+bdcom-0ubuntu3) ... Removing old bcmwl-5.60.48.36+bdcom DKMS files...

[Code].....

View 9 Replies View Related

General :: Getting Back To "stdin" After Redirecting A File To A Particular Program?

Nov 22, 2010

I need to achieve a particular effect using bash's redirection facilities.I know that I can redirect a file to some program's standard input:[user@host]$ application < file.txtThe thing is, I'd like to know can I regain control of this program's input after the file content's have been passed to it. In other words, I'd like to run a command similar to the above, and then, instead of the termination of the application, I'd want it to wait for further commands from standard input (keyboard).

As I write this question, it occured to me that I could probably write another application (or a script), that would at first write some data to standard output and then act as echo, like:[user@host]$ stdin_proxy.sh | applicationWould it work, and is there any better way to do so? There are a bunch of Googleable tutorials covering this issue, but they all amount to one advice - "reopen the stdin after the file contents have been read".

View 1 Replies View Related

General :: Error - Gzip :stdin:input /output Error /bin /gstar :unexpected EOF In Archive

Mar 28, 2011

when iam opening my dec_backup folder the folling error is appering :

the error is gzip :stdin:input /output error
/bin /gstar :unexpected EOF in archive
/bin /gstar: error is not recoverable :exesting now

View 1 Replies View Related

General :: Redirecting STDOUT Of Previous Command To STDIN Of Next Command

Nov 20, 2009

i'm trying to redirect the output of a command to the input of the next command. not sure if i'm going about this the right way. an easy method would be just to store the output of the previous command in a file and redirect input to read that file, but i'm curious to see if this can be done without writing to any files.

View 9 Replies View Related

General :: How To Clear History

Nov 30, 2010

How to clear history in LINUX?

Which command?

And how to remove permissions which is given for a user to be group admin? by this command- gpasswd -A ram sales

Where ram is user sales is group

How to deselect him as admin?

View 7 Replies View Related

General :: How To Clear Memory Buffer

Nov 18, 2009

I am having a Oracle server installed on Linux server. I want to clear the buffers after a certain time interval. I use the following command for the same.

echo 3 > /proc/sys/vm/drop_caches

Can I have a script which will execute the above script after certain time interval OR a script which will execute the above command when certain memory size is reached.

View 1 Replies View Related

General :: How To Clear Out SSH Agent Entries (on Mac OS X)

Apr 16, 2011

I'm running OS X and it appears that after SSHing to several machines, using identity files, my ssh-agent builds up a lot of identity / keys and then offers too many sometimes to a remote machines, causing them to kick me off before connecting.
Received disconnect from 10.12.10.16: 2: Too many authentication failures for cwd

It's pretty obvious what's happening, and this page talks about it in more detail:
SSH servers only allow you to attempt to authenticate a certain number of times. Each failed password attempt, each failed pubkey/identity that is offered, etc, take up one of these attempts. If you have a lot of SSH keys in your agent, you may find that an SSH server may kick you out before allowing you to attempt password authentication at all. If this is the case, there are a few different workarounds.

Rebooting clears the agent and then everything works OK again. I can also add this line to my .ssh/config file to force it to use password authentication:
PreferredAuthentications keyboard-interactive,password
Anyhow, I saw the note on the page I referenced talking about deleting keys from the agent, but I'm not sure if that applies on a mac since they appear to be cleared after reboot anyhow. So, my question is, is there a simple way to clear out all keys in the ssh-agent (the same thing that happens at reboot)?

View 1 Replies View Related

General :: Reset / Clear Blacklisted Myself?

Jan 11, 2010

I recently became co-owner of a server, however upon trying to ssh it became apparent the root admin gave me the wrong password by mistake;
After trying several times with the wrong pasword thinking I might have mistyped I have now blacklisted myself, huzzah.

How can I reset or clear the blacklist?

View 2 Replies View Related

General :: How Do You Clear Reboot History

May 24, 2011

I don't mind a few lines of reboots, but this is getting rather long:

How can I clear (or reduce) the history that comes up when ssh to my host?

View 9 Replies View Related

General :: How To Clear Out Mqueue Directory

Apr 12, 2011

My system is old. Not debian.How do I clear out the mqueue directory? I don't want to delete it....just clear it out of the email that is clogging up my var partition. This old command doesn't seem to work anymore:find /var/spool/mqueue -exec rm'{}' ;Anybody know of the command to clear my mqueue.

View 5 Replies View Related

General :: Clear Bad Shortcuts From Gnome-do Cache?

Feb 11, 2010

I am using ubuntu and gnome-do and have in my gnome-do some bad shortcuts ( they even have a grey X icon ) that i cant figure out how to delete from the list. I thought gnome do has some cache but its been a while and they are still there :(

how to clear them from the list ?

Update: I deleted the ~/local/share/gnome-do folder and still no success

View 3 Replies View Related

General :: Clear IP Address Of Ethernet Interface?

Jun 17, 2010

What is the Linux command to clear IP address of an interface without bringing it down and/or restarting network services. Seems strange ifconfig is able to change IP address but has no option to clear it, or am I wrong?

EDIT:As simple as ifconfig eth0 0.0.0.0. They should have put it in the man

View 3 Replies View Related

General :: Cant Get Clear Mint Main Menu?

Jun 26, 2011

i am dragged myself from windows to mint 10 julia..while downloading the screenshots is like <http://www.linuxmint.com/pictures/screenshots/julia/menu.png> but after installation i got only menu like the basic menulike in ubuntu.am new to minti installed inside windows.am i done anything wrong with installation

View 3 Replies View Related

General :: Server Commands To Clear Mail?

Mar 13, 2011

My var partition is full. The main culprit is NOW the mail file. What is the command to empty the mail files?The mqueue and clientmqueue files are now low on usage but the mail file is responsible for filling up the var partition.

View 1 Replies View Related

Ubuntu :: Stdin: Error 0 At Boot

Mar 7, 2011

i've tryed to get rid of the ugly plymouth splash screen and this outpout at boot now:

stdin: error 0

and so on... It also appears in my /var/log/boot.log and /var/log/casper.log. But the OS works, just like before. I would like to know how can i get rid of this error. Or how can i hide it? Can i redirect the output to dev null at boot time?

Here is boot.log

Code:
stdin: error 0
Generating locales...
sl_SI.UTF-8... up-to-date
Generation complete.

[Code]....

Because it is really annoying to see an "error" when your computer boots, even if it is not really an error

View 2 Replies View Related

General :: Filesystems - Totally Clear The Filesytem's Cache?

Aug 4, 2011

In a performance test, I want to bypass the influence of cache of linux system (including page cache/inode cache and so on). I have tried O_DIRECT flag, but it's turned out that direct I/O is still "enjoy" the effect of some cache.Is there a thorough way to close the effect of system cache?

View 2 Replies View Related

General :: Clear A Terminal Screen While Tailing A File?

Aug 30, 2011

I'm looking for something identical to what command-k does in a terminal window on a Mac.

clear / ^L does not work.

View 1 Replies View Related

General :: Clear Screen Command For BASH Shell

Jan 21, 2010

I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands.

I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as
alias cls='^L'

This is how i defined other aliases e.g.

And they work. Hence I assume cls will work too but this is what I get when I try to give cls on command prompt. Am i missing something? Is there a way to do this?

Then someone suggested, You cannot alias keystrokes to commands or vice versa. You could just alias cls to an echo command: echo -en "x0c"

And I added the following to .bashrc,

Sourced the .bashrc file. No errors but cls still does not clear the screen. Infact when I typed the echo -en "x0c on command prompt as well, nothing happened. What does this command do?

View 3 Replies View Related

General :: SSH And Stop Password Being Shown In Clear Text?

Jan 6, 2011

I have a headless server running Centos and I often login in remotely to administer it. I have passwordless login and sometimes run commands remotely via ssh from a client machine. I've tried to shut the server remotely but have come across a small problem. Here is the output of the command I use to shutdown :Code:unclec@linux-desktop $ ssh centos 'sudo /sbin/shutdown -h now 'PASSWORD : 123ABCAs passwordless login is set up I do not need to enter a password to ssh BUT as I am running sudo on the server I am asked to enter my centos unclec password and this is shown in clear text on my local machine terminal. Is there a way to prevent this or should I edit the sudoers file on centos so it does not ask me to enter the password when "sudoing" ?

View 1 Replies View Related

Programming :: Bash: How To Discard Unwanted Stdin

Jun 22, 2010

Often in bash we read lines from stdin in a loop and implicitly discard the remaining stdin by terminating the loop. Is it possible to discard it without terminating the loop? It could lead to smaller code.

Here's an example which uses two loops and below is the same algorithm assuming unwanted stdin can be discarded

Code:
found=
while read destination gateway _
do
[[ $destination = default ]] && found=yes && break
done <<< "$( route )"

[Code].....

View 12 Replies View Related

Programming :: Clearing Stdin Obtained From Pipe

Mar 14, 2010

I have a small program that reads stdin from a pipe using fgets. Now fgets blocks for the first line but after that it will not block.

The code, my_echo.c -
int main(int argc, char **argv) { char buf [2000] ;
char* pc ; printf("hello ") ; while (1)
{ buf[0] = (char) 0 ;
pc = fgets(buf, sizeof(buf), stdin);
if (pc != NULL) printf("%s ",buf); } return 0; }

How its called
* In terminal window 1: ./my_echo < my_fifo
* In terminal window 2: echo "1234" > my_fifo
* In terminal window 1: prints hello then 1234.
* Checking with ksysguard or top shows that my_echo is consuming 40% of CPU time.

Adding a few printf's shows that the gets is not blocking and returns a null pointer.
* In terminal window 2: echo "qwerty" > my_fifo
* In terminal window 1 qwerty prints.
I want a read function that does in fact block so my program does not tie up CPU time, read does not block.

View 7 Replies View Related

Programming :: Write A Script Which Will Get A Number From STDIN?

Dec 15, 2008

I need to write a script which will get a number from STDIN and then with that number echo a set number of questions (its for a firewall config). Heres what I want the user to receive.

How many ports do you want open? 3

1. specify port: 80
2. specify port: 21
3. specify port: 23

In the background this will echo a command out to a text file which will read as follows:

open port 80
open port 21
open port 23

I've done this before but I've completely forgotten how

View 2 Replies View Related

Programming ::make AWK Do *something* Without Giving It Any Stdin Nor Inputfile?

Oct 10, 2010

[code]...

I've given the output from `df` on AWK's stdin. But what I wonder is if there's a way to get AWK to run `df` itself, produce the same output, and exit? Doesn't seem to be that simple. Here's some examples: Works for some reason, and I think only in Bash (nothing is required in the $()

[code]...

does AWK absolutely need *something* on stdin, before it begins to process the data? Can it be made to open a file or stream internally, act upon that as though it were the stdin, and exit?

View 14 Replies View Related

Programming :: How To Redirect Stdin For Child Process

Aug 18, 2010

I'm trying to write a shell script that do ftp and download file periodically, this script should be called by a daemon running in the background.

the shell script "script.sh" is as follows:

Code:
yafc ftp://test:test@192.168.1.225:21 < commands
and the "commands" files is

Code:
d Root/md5* /
quit

if I run script.sh it will work just fine. But when the daemon software calls the "script.sh", the script will send ftp login request to the ftp server, but will not even answer the username or anything.

I believe it is something about child process redirection, but I don't know how to deal with it.

This problem is not only with yafc, it is the same with any ftp client or any application like telnet and so.

View 4 Replies View Related

Programming :: Read From Stdin In Perl Do Not Wait For EOF?

Apr 28, 2010

I am trying to read one line at a time in perl and not wait for stdin eof to start the action:

Code:
foreach(<STDIN>){
<do something>
}

if i pipe ls into it, it waits for ls to be done before doing the action.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved