Sponsored Content
Top Forums Shell Programming and Scripting Read input while another command is running && Post 302901744 by Kiah07 on Thursday 15th of May 2014 10:47:12 AM
Old 05-15-2014
Read input while another command is running &&

This script runs tshark, then displays the output. I want to read a keypress at all times throughout this script, especially during the 10 seconds that tshark is running. This code however, only takes input before tshark runs.

Code:
#!/bin/bash
main() {
while (( "1" == "1" )) ; do
keypress && list=`timeout 10s tshark -l -i eth0`
echo "$list"
done
}

keypress() {
read -t 5 -s -n 1 key &&
if [[ "$key" == "q" ]] ; then
echo "quit"
exit
fi
return 0
}

main

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

hi, am a new learner to shell programming. i have a script which will prompt for user to key in their name & display their name afterwards. script ===== echo "Pls enter your name:" read name echo "Your name is $name." output ===== Pls enter your name: Bob Your name is Bob. what... (2 Replies)
Discussion started by: newbie168
2 Replies

2. SuSE

inconsistent ls command display at the command prompt & running as a cron job

Sir, I using the following commands in a file (part of a bigger script): #!/bin/bash cd /opt/oracle/bin ls -lt | tail -1 | awk '{print $6}' >> /tmp/ramb.out If I run this from the command prompt the result is: 2007-05-16 if I run it as a cron job then... (5 Replies)
Discussion started by: rajranibl
5 Replies

3. UNIX for Dummies Questions & Answers

sleep 10 && command doesn't work

Hi there, I found a trick to easily postpone a command by a few seconds: supernova:~# sleep 10 && command &If you logout, the command should still be executed... But not all the time. Could anyone of you explain me why the following command is executed even after logging out: supernova:~# sleep... (2 Replies)
Discussion started by: chebarbudo
2 Replies

4. UNIX for Dummies Questions & Answers

Problem with xterm & tcsh & sourcing a script in a single command

Hi friends, I have a script that sets the env variable path based on different conditions. Now the new path variable setting should not done in the same terminal or same shell. Only a new terminal or new shell should have the new path env variable set. I am able to do this only as follows: >cd... (1 Reply)
Discussion started by: sowmya005
1 Replies

5. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

6. Shell Programming and Scripting

Replace & sign to &amp word

Hi, I have text file abc.txt. In this file, I have the following data. Input: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith & Mrs Smith Mr Smith& Mrs Smith Mr Smith &Mrs Smith Output: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith &amp Mrs Smith Mr Smith&amp... (4 Replies)
Discussion started by: naveed
4 Replies

7. Shell Programming and Scripting

Using Grep & find & while read line in a script

Hello people! I would like to create one script following this stage I have one directory with 100 files File001 File002 ... File100 (This is the format of content of the 100 files) 2012/03/10 12:56:50:221875936 1292800448912 12345 0x00 0x04 0 then I have one... (0 Replies)
Discussion started by: Abv_mx81
0 Replies

8. Shell Programming and Scripting

[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing. What I have understood is : -- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found -- branch B="$B $C" is to install the software --... (4 Replies)
Discussion started by: jcdole
4 Replies

9. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

10. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies
DNSPKTFLOW(1p)						User Contributed Perl Documentation					    DNSPKTFLOW(1p)

NAME
dnspktflow - Analyze and draw DNS flow diagrams from a tcpdump file SYNOPSIS
dnspktflow -o output.png file.tcpdump dnspktflow -o output.png -x -a -t -q file.tcpdump DESCRIPTION
The dnspktflow application takes a tcpdump network traffic dump file, passes it through the tshark application and then displays the resulting DNS packet flows in a "flow-diagram" image. dnspktflow can output a single image or a series of images which can then be shown in sequence as an animation. dnspktflow was written as a debugging utility to help trace DNS queries and responses, especially as they apply to DNSSEC-enabled lookups. REQUIREMENTS
This application requires the following Perl modules and software components to work: graphviz (http://www.graphviz.org/) GraphViz (Perl module) tshark (http://www.wireshark.org/) The following is required for outputting screen presentations: MagicPoint (http://member.wide.ad.jp/wg/mgp/) If the following modules are installed, a GUI interface will be enabled for communication with dnspktflow: QWizard (Perl module) Getopt::GUI::Long (Perl module) OPTIONS
dnspktflow takes a wide variety of command-line options. These options are described below in the following functional groups: input packet selection, output file options, output visualization options, graphical options, and debugging. Input Packet Selection These options determine the packets that will be selected by dnspktflow. -i STRING --ignore-hosts=STRING A regular expression of host names to ignore in the query/response fields. -r STRING --only-hosts=STRING A regular expression of host names to analyze in the query/response fields. -f --show-frame-num Display the packet frame numbers. -b INTEGER --begin-frame=INTEGER Begin at packet frame NUMBER. Output File Options These options determine the type and location of dnspktflow's output. -o STRING --output-file=STRING Output file name (default: out%03d.png as PNG format.) --fig Output format should be fig. -O STRING --tshark-out=STRING Save tshark output to this file. -m --multiple-outputs One picture per request (use %03d in the filename.) -M STRING --magic-point=STRING Saves a MagicPoint presentation for the output. Output Visualization Options: These options determine specifics of dnspktflow's output. --layout-style Selects the graphviz layout style to use (dot, neato, twopi, circo, or fdp). -L --last-line-labels-only Only show data on the last line drawn. -z INTEGER --most-lines=INTEGER Only show at most INTEGER connections. -T --input-is-tshark-out The input file is already processed by tshark. Graphical Options: These options determine fields included in dnspktflow's output. -t --show-type Shows message type in result image. -q --show-queries Shows query questions in result image. -a --show-answers Shows query answers in result image. -A --show-authoritative Shows authoritative information in result image. -x --show-additional Shows additional information in result image. -l --show-label-lines Shows lines attaching labels to lines. --fontsize=INTEGER Font Size Debugging: These options may assist in debugging dnspktflow. -d --dump-pkts Dump data collected from the packets. -h --help Show help for command line options. COPYRIGHT
Copyright 2004-2012 SPARTA, Inc. All rights reserved. See the COPYING file included with the DNSSEC-Tools package for details. AUTHOR
Wes Hardaker <hardaker@users.sourceforge.net> SEE ALSO
Getopt::GUI::Long(3) Net::DNS(3) QWizard.pm(3) http://dnssec-tools.sourceforge.net/ perl v5.14.2 2012-06-21 DNSPKTFLOW(1p)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy