Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2007 11:12:40 -0800
From:      Garrett Cooper <youshi10@u.washington.edu>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: Command Execution Using Script - Similar to Windows Batch File-Like Script (Coding Help)
Message-ID:  <C2CE9913-1309-4247-A85F-6EB716C3668E@u.washington.edu>
In-Reply-To: <524906.28483.qm@web59207.mail.re1.yahoo.com>
References:  <524906.28483.qm@web59207.mail.re1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C2CE9913-1309-4247-A85F-6EB716C3668E>