Sponsored Content
Top Forums Shell Programming and Scripting Help with Bash piped while-read and a read user input at the same time Post 302601421 by MyMorris on Thursday 23rd of February 2012 03:54:12 PM
Old 02-23-2012
Help with Bash piped while-read and a read user input at the same time

Hi
I am new to writing script and want to use a Bash Piped while-read and read from user input.

if something happens on server.log then do while loop or if something happend on user input then do while loop.

Pseudocode something like:
tail -n 3 -f server.log | while read serverline || read -p # -e promptline
do
if something happend on promptline then do this
if something happend serverline then do this

I appreciate all help.
Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

getline to read input from a user

Hi, The gcc compiler has warned about using gets(), so I've been trying my hand at getline. Problem is that I've been able to read from a file, but what I really need is to read from a user's input. I want to use getline like a scanf() command, but I can't figure what to substitute for the fp... (6 Replies)
Discussion started by: sdsd
6 Replies

2. UNIX for Dummies Questions & Answers

How to read a line of text from user input?

Hiii I wanna a read a line of text from standard input. The user enter data like this way name phone_no month1_salary month2_salary that is user enter the name ,phone no and salary of 2 months in a single line by giving spaces. I wanna add the 3rd and 4th fields ...ie add both... (4 Replies)
Discussion started by: krishnampkkm
4 Replies

3. Shell Programming and Scripting

BASH - read use a path as input

I am trying to script simply data transfer. I would like to have the user input the source "SRC" (/Volumes/DriveName/Users/johnq123) and then name the directory that the copied information will go to, "DST" . put I can't get it to work - #!/bin/bash ... (8 Replies)
Discussion started by: dropkick888
8 Replies

4. AIX

Read input data within a specified period of time

Hi All, I am working on a script which requires an input from user within one 1 min. So if the user gives the required input within 1 min., it will execute on the basis of input provided by the user.Other wise it will execute on a default value(hard coded inside the script). Now, I am... (19 Replies)
Discussion started by: rajsharma
19 Replies

5. Shell Programming and Scripting

Solaris- Read command from user input

I need to write a bourne shell script (solaris 10) that accepts input from the user. The input will be a command- any command like ls/ pwd/ mv etc. After the input is read, the shell must execute the command supplied by the user. I know we use read to play with user inputs. Just not sure how to... (2 Replies)
Discussion started by: PDManc
2 Replies

6. Shell Programming and Scripting

Using read to prompt for editable user input in Bash 3

Below is a simple script to prompt for user input while suggesting an editable default value at the prompt: shortname=user1 read -e -i $shortname -p "Please enter the username you would like to add: " input USERNAME="${input:-$shortname}" Please enter the username you would like to add:... (3 Replies)
Discussion started by: woodson2
3 Replies

7. Shell Programming and Scripting

BASH - read does not wait for user input in some circumstances

Hello. I am running 2 scripts : script_1 and script_2 These scripts are run as root Script 2 contains : #!/bin/bash # # ~/bin/script_2 # E_BAD_PARAM=115 # date2stamp () { date --date "$1" +%Y-%m-%d___%H:%M:%S } # USER_NAME=$1 NB_PARAM=$# PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies

8. Shell Programming and Scripting

Perl to read user input

I am creating a bash that uses perl . The below code closes before the input is entered. If I run the perl as a .pl it is fine. What am I doing wrong? Thank you :). #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv print... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Shell read command is not waiting for user input

Hi, i am working on one automation , for that i have writing one shell program that take user input in "while read line" block. but read command is taking value that is readed by While block. while read line; do command 1; command 2 echo -n "Do you want to continute > " read rsp... (2 Replies)
Discussion started by: ranvijaidba
2 Replies

10. Shell Programming and Scripting

Unable to read user input inside a loop

Hi, This query is a part of a much more lengthy script. I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to. Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies
Sys::Statistics::Linux::NetStats(3pm)			User Contributed Perl Documentation		     Sys::Statistics::Linux::NetStats(3pm)

NAME
Sys::Statistics::Linux::NetStats - Collect linux net statistics. SYNOPSIS
use Sys::Statistics::Linux::NetStats; my $lxs = Sys::Statistics::Linux::NetStats->new; $lxs->init; sleep 1; my $stat = $lxs->get; Or my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => $file); $lxs->init; my $stat = $lxs->get; DESCRIPTION
Sys::Statistics::Linux::NetStats gathers net statistics from the virtual /proc filesystem (procfs). For more information read the documentation of the front-end module Sys::Statistics::Linux. NET STATISTICS
Generated by /proc/net/dev. rxbyt - Number of bytes received per second. rxpcks - Number of packets received per second. rxerrs - Number of errors that happend while received packets per second. rxdrop - Number of packets that were dropped per second. rxfifo - Number of FIFO overruns that happend on received packets per second. rxframe - Number of carrier errors that happend on received packets per second. rxcompr - Number of compressed packets received per second. rxmulti - Number of multicast packets received per second. txbyt - Number of bytes transmitted per second. txpcks - Number of packets transmitted per second. txerrs - Number of errors that happend while transmitting packets per second. txdrop - Number of packets that were dropped per second. txfifo - Number of FIFO overruns that happend on transmitted packets per second. txcolls - Number of collisions that were detected per second. txcarr - Number of carrier errors that happend on transmitted packets per second. txcompr - Number of compressed packets transmitted per second. ttpcks - Number of total packets (received + transmitted) per second. ttbyt - Number of total bytes (received + transmitted) per second. METHODS
new() Call "new()" to create a new object. my $lxs = Sys::Statistics::Linux::NetStats->new; Maybe you want to store/load the initial statistics to/from a file: my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => '/tmp/netstats.yml'); If you set "initfile" it's not necessary to call sleep before "get()". It's also possible to set the path to the proc filesystem. Sys::Statistics::Linux::NetStats->new( files => { # This is the default path => '/proc', netdev => 'net/dev', } ); init() Call "init()" to initialize the statistics. $lxs->init; get() Call "get()" to get the statistics. "get()" returns the statistics as a hash reference. my $stat = $lxs->get; raw() The same as get_raw() but it's not necessary to call init() first. get_raw() Call "get_raw()" to get the raw data - no deltas. EXPORTS
No exports. SEE ALSO
proc(5) REPORTING BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-03-09 Sys::Statistics::Linux::NetStats(3pm)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy