From owner-freebsd-questions@FreeBSD.ORG Thu Aug 4 17:46:21 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 432FC16A41F for ; Thu, 4 Aug 2005 17:46:21 +0000 (GMT) (envelope-from pauls@utdallas.edu) Received: from smtp1.utdallas.edu (smtp1.utdallas.edu [129.110.10.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 108E343D45 for ; Thu, 4 Aug 2005 17:46:21 +0000 (GMT) (envelope-from pauls@utdallas.edu) Received: from utd59514.utdallas.edu (utd59514.utdallas.edu [129.110.3.28]) by smtp1.utdallas.edu (Postfix) with ESMTP id 6FD07388C95 for ; Thu, 4 Aug 2005 12:46:20 -0500 (CDT) Date: Thu, 04 Aug 2005 12:46:20 -0500 From: Paul Schmehl To: freebsd-questions@freebsd.org Message-ID: X-Mailer: Mulberry/3.1.6 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Shell script question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2005 17:46:21 -0000 I'm working on a shell script to use p0f to identify "unauthorized" hosts on our network. In the script I use an echo command to see what the output of the command is. This is what it looks like: /usr/local/bin/p0f -i xl0 -N -l -o /root/capture.1123177152.log 'src net 10.0.0.0/8 or src net 129.110.0.0/16' If I paste the output of the echo command to the cli and hit enter, p0f runs and writes to the log. Yet when I actually try to run that same command from the script, p0f complains: pcap_compile: illegal token: ' See man tcpdump or p0f README for help on bpf filter expressions. Here's the script. It's very simple right now, but there's a lot more work to be done. I first have to figure out this problem, though: #!/bin/sh P0F=/usr/local/bin/p0f EPOCH_DATE=`date -j -f "%a %b %d %T %Z %Y" "\`date\`" "+%s"` LOG=/root/capture.${EPOCH_DATE}.log NIC="-i xl0" ARGS="-N -l -o ${LOG}" DAEMON="-d" FILTER="'src net 10.0.0.0/8 or src net 129.110.0.0/16'" echo "${P0F} ${NIC} ${ARGS} ${DAEMON} ${FILTER}" ${P0F} ${NIC} ${ARGS} ${FILTER} Why is p0f complaining about the bpf filter? I've tried escaping the single quotes, but that generates a different error. I don't understand why the identical command works on the cli, but not in the script. Paul Schmehl (pauls@utdallas.edu) Adjunct Information Security Officer University of Texas at Dallas AVIEN Founding Member http://www.utdallas.edu/ir/security/