Sponsored Content
Top Forums Shell Programming and Scripting Newb with While loop question Post 302439090 by dddkkk on Wednesday 21st of July 2010 07:27:34 PM
Old 07-21-2010
Newb with While loop question

My first post here....
I have a few years exp with linux distros and some very basic Python..Ive been intent on learning shell scripting the last few weeks. Please excuse my crude efforts.

I am running a program that takes network data containing US city names in plain text. I am TRYING to write a shell scripts that will filter at the nic for specific cities (using tcpdump) and alert both on the monitor and with audio ( and eventually a text message)

Tcpdump and the filters work well however I cant figure out how to accurately display on the monitor and play the wav when a select city is found. (My audio script works well on its own).

This works for me so far...
Code:
tcpdump -s 700 -t -n -N -X src 67.1.1.1 | grep -E "Miami|Austin|Chicago|Reno"'

But when I try to add an audio alert with a loop...

Code:
#! /bin/bash/

func1='tcpdump -s 700 -t -n -N -X src 67.11.11.11 | grep -E "Miami|Austin|Chicago|Reno"'

while true; do
        [ "$func1" ]
        if [ "$func1"!="" ]
       then
            echo " found at " $(date)
            play sound.wav
       else
            continue
       fi
done

The above script comes back comes back positive with every pass of the loop and just prints "found at"

Can anyone give me some direction?
Thanks
Dave (hmm my indents didnt take here. I believe that all my indents are correct. Its the script that is incorrect)

Last edited by fpmurphy; 07-21-2010 at 10:14 PM.. Reason: code tags added
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

newb shell question

I know this is a total begginer question but what is wrong with this picture. My loop wont loop, it just drops me back to the prompt and gives the error "unary operator expected". Any help would be appreciated. here it is, #!/bin/sh selection= while do cat << MENU 1)List files in... (2 Replies)
Discussion started by: Fokus
2 Replies

2. UNIX for Dummies Questions & Answers

help for a newb

ok i just installed FreeBSD 4.8 on a computer i had lying around and it was working ok but then when i tried to set up KDE's xdm (kdm) i think i must have configured the login manager wrong because i cant login through the kdm and therefore i can log in to BSD at all?! please can someone help me... (5 Replies)
Discussion started by: h3x
5 Replies

3. UNIX for Dummies Questions & Answers

Newb question

I don't even know if this should go here but I just would like to know what this means: d0e45878043844ffc41aac437e86b602 I know absolutely nothin' about UNIX, and I found this in a SQL table in a board I run. Someone please tell me what that is in "normal" mode. Pardon me for my... (4 Replies)
Discussion started by: daeglin
4 Replies

4. UNIX for Dummies Questions & Answers

Ok I'm a Newb, Please Help

I am wanting to download the Linux Program. When i go to download it I see several things to download. What do i download exactly? Then what do I do to install it. Also I have partitioned my hard drive to make way for Linux on the other part to play with it, will any problems arise from this? I... (3 Replies)
Discussion started by: Seeto
3 Replies

5. Shell Programming and Scripting

Newb scripting question, I get the error script not found

This is probably a really simple problem, but goes easy on me I'm still a newb. The problem I have is that a script (we'll call it script.script) I edited won't run for some reason, I get the error "ksh: script.script: not found" The location of my script is as follows: /home/users/arkitech ... (3 Replies)
Discussion started by: Arkitech
3 Replies

6. Shell Programming and Scripting

Another newb question: how to use test for zero-length string ?

Assume $x equals "". If I try: if test -n $x I get the "Expression syntax" error. It works in Linux but not in unix bash. In unix bourne I get "test: argument expected" (4 Replies)
Discussion started by: lumix
4 Replies

7. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

8. Shell Programming and Scripting

Newb question about getting a word from a text file

Hi everyone. I am new to shell scripting and have been looking at quite a few web pages to try and figure this out, but to no avail. What I am trying to do is get a value from a text file that contains a paragraph of information.. Something similar too: Welcome to random script You are... (1 Reply)
Discussion started by: elemenopee
1 Replies

9. UNIX for Dummies Questions & Answers

NEWB Question - BASH COMMAND RESULT for ${0##*/}

This should be extremely simple and someone will probably answer it in .5 seconds. I need to know what: VARIABLE=${0##*/} does? I do not have a shell handy to just try it in. I am reading through some scripts and need to understand this line. Any help is appreciated. Many thanks! -... (3 Replies)
Discussion started by: chrisgoetz
3 Replies

10. Shell Programming and Scripting

Question around For Loop

Hi, I have a variable called result that get the the below value i.e two lines assigned../logs/mymac/myserver.log:####<Jun 7, 2015 12:56:54 PM EDT> <myserver.my.bank.com> <mymac> < ExecuteThread: '5' for queue:\ 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1434640> <BEA-0900>... (0 Replies)
Discussion started by: shifahim
0 Replies
DRIFTNET(1)						      General Commands Manual						       DRIFTNET(1)

NAME
driftnet - capture images from network traffic and display them in an X window; optionally, capture audio streams and play them. SYNOPSIS
driftnet [options] [filter code] DESCRIPTION
Driftnet watches network traffic, and picks out and displays JPEG and GIF images for display. It is an horrific invasion of privacy and shouldn't be used by anyone anywhere. It has been described as `a graphical tcpdump(8)', `EtherPeg for Unix', and called all sorts of nasty names by people on Freshmeat. It is also possible to use driftnet to capture MPEG audio data from the network and play it through a player such as mpg123(1). Images may be saved by clicking on them. OPTIONS
-h Print a summary of usage. -v Print additional details of packets captured to the terminal. -b Beep when a new image is displayed. -i interface Listen to packets on interface. By default, driftnet will try to pick up traffic on all interfaces, but this does not work with all versions of pcap(3); on such systems, an interface must be specified. On some systems, driftnet can only use promiscuous mode if an interface is specified. -f file Instead of listening on an interface, read captured packets from a pcap(3); dump file; file can be a named pipe for use with Kismet or similar. -p Do not put the interface into promiscuous mode. -a Operate in `adjunct mode', where driftnet gathers images for use by another program, such as Jamie Zawinski's webcollage. In this mode, no window is displayed; images are captured and saved in a temporary directory, and their names written on standard output. -m number In adjunct mode, silently drop images if there are more than number in the temporary directory. It is assumed that another process will delete images which it has processed. -x prefix The filename prefix to use when saving images, by default `driftnet-'. -d directory Use directory to store temporary files. Driftnet will clear this directory of its own temporary files on exit, but will not delete the directory or any other files. -s Attempt to capture streamed audio data from the network, and either play it or, in adjunct mode, save it in files. At present this only works with MPEG data. -S Capture streamed audio data only, ignoring images. -M command Use the named command to play MPEG audio data. The command, which is executed using the shell, should accept MPEG frames on standard input. The default is `mpg123 -'. filter code Additional filter code to restrict the packets captured, in the libpcap syntax. User filter code is evaluated as `tcp and (filter code)'. SEE ALSO
tcpdump(8), pcap(3), webcollage(1), mpg123(1), http://www.etherpeg.org/, http://freshmeat.net/projects/driftnet/, http://www.ex-parrot.com/~chris/driftnet/. AUTHOR
Chris Lightfoot <chris@ex-parrot.com> VERSION
Driftnet, version 0.1.6. $Id: driftnet.1.in,v 1.7 2004/04/26 14:42:36 chris Exp $ COPYING
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. DRIFTNET(1)
All times are GMT -4. The time now is 02:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy