On 1/16/07, linux quest <email@example.com> 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.
Considering the question a subtle joke or something, let me
take the bait and help you.
File extensions do not matter much in Unix. File permissions
do. If you want to make an executable script, you'll have to
state in its first line what kind of script it is, or, more
precisely, what program should interpret it. The line is
usually called "shebang" because it starts with "#!". After
that an interpreter must be specified. For shell scripts
(you want to start with them!) use "#!/bin/sh" (without the
quotes) in the first line.
After that line just add more lines with commands.
"nmap 22.214.171.124" is a perfectly valid command, you can just
place it on a separate line.
After all that you need to change permissions of this new
file you've just created to allow execution. Just do:
# chmod a+x <file>
You can then try to execute the file either by calling
it by full path or by changing into its directory and