From owner-freebsd-questions@FreeBSD.ORG Tue Jan 16 19:12:42 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8B0716A492 for ; Tue, 16 Jan 2007 19:12:42 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout2.cac.washington.edu (mxout2.cac.washington.edu [140.142.33.4]) by mx1.freebsd.org (Postfix) with ESMTP id B550213C442 for ; Tue, 16 Jan 2007 19:12:42 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.141] (may be forged)) by mxout2.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id l0GJCgGW002775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Jan 2007 11:12:42 -0800 X-Auth-Received: from [192.168.0.102] (dsl254-013-145.sea1.dsl.speakeasy.net [216.254.13.145]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id l0GJCfbA031905 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Tue, 16 Jan 2007 11:12:42 -0800 Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <524906.28483.qm@web59207.mail.re1.yahoo.com> References: <524906.28483.qm@web59207.mail.re1.yahoo.com> X-Gpgmail-State: !signed Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Garrett Cooper Date: Tue, 16 Jan 2007 11:12:40 -0800 To: FreeBSD Questions X-Mailer: Apple Mail (2.752.2) X-PMX-Version: 5.2.2.285561, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.1.16.105933 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0' Subject: Re: Command Execution Using Script - Similar to Windows Batch File-Like Script (Coding Help) 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: Tue, 16 Jan 2007 19:12:42 -0000 On Jan 16, 2007, at 1:00 AM, linux quest wrote: > Dear FreeBSD Communities, > > Lets say, I wanted to create a Perl script to execute a very simple > nmap command as listed below, may I know how do I do it? > > unix# nmap 192.168.1.2 > > I know we need to save it in .pl extension. May I know what else I > need to do? > > I have researched and google this for the entire week, but I still > can't find the solution. For example in Windows, all I need to do > is to type "nmap 192.168.1.2" and save it in a text file with the > extension .bat - and everything will be taken care of. > > I hope someone can share with me the simple coding to solve this > problem. > > Thank you so much, guys :) > > Regards, > Linux Quest > > Regards, > Linux Quest If you just want to see if a host is up.. #!/bin/sh # /usr/bin/ping -c 1 192.168.1.2 ..would suffice. Substitute /usr/bin/ping -c 1 for whatever command and arguments you want to run. Google "beginner bash manual" (note that it's for bash--the bourne again shell, not bourne shell--sh), but many of the same semantics in bash applying to sh. -Garrett