OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
exec('nmap');
#calls nmap
print "domain name: "
#asks for domain name
$dom = ;
#gets domain name
How can i get the domain into the program nmap
Help is greatly appreciated
Comments
However you do not want to exec it.
Just do the following.
print "Enter in hostname";
$host=;
chomp($host);
system("nmap $host");
print "
Done
";
: OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
:
: exec('nmap'); #calls nmap
: print "domain name: " #asks for domain name
: $dom = ; #gets domain name
:
: How can i get the domain into the program nmap
:
: Help is greatly appreciated
:
I did it one way for you now let me do another way.
Below, will work if you just need to call nmap.
If you want your program to work w. nmap you can also
do the following.
Being that you are using the exec nmap Im assuming you are in
a Unix/linux OS.
One thing you can do is export the perl vars into your shell.
That way for instance you can just use nmap and call shell variables.
$host=;
chomp($host);
system("export PERLSCRIPTVAR="$host"");
#then to call it just use nmap $PERLSCRIPTVAR
Hope these two explanations help.
: Okay first off that is not making the program nmap simpler to use. If anything its making it more time consuming.
: However you do not want to exec it.
: Just do the following.
:
: print "Enter in hostname";
: $host=;
: chomp($host);
: system("nmap $host");
: print "
Done
";
:
:
:
: : OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
: :
: : exec('nmap'); #calls nmap
: : print "domain name: " #asks for domain name
: : $dom = ; #gets domain name
: :
: : How can i get the domain into the program nmap
: :
: : Help is greatly appreciated
: :
:
:
Theres a way just cant figure it out
: Okay I may of misunderstood.
:
: I did it one way for you now let me do another way.
: Below, will work if you just need to call nmap.
: If you want your program to work w. nmap you can also
: do the following.
: Being that you are using the exec nmap Im assuming you are in
: a Unix/linux OS.
:
: One thing you can do is export the perl vars into your shell.
: That way for instance you can just use nmap and call shell variables.
:
: $host=;
: chomp($host);
: system("export PERLSCRIPTVAR="$host"");
: #then to call it just use nmap $PERLSCRIPTVAR
:
: Hope these two explanations help.
:
:
:
: : Okay first off that is not making the program nmap simpler to use. If anything its making it more time consuming.
: : However you do not want to exec it.
: : Just do the following.
: :
: : print "Enter in hostname";
: : $host=;
: : chomp($host);
: : system("nmap $host");
: : print "
Done
";
: :
: :
: :
: : : OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
: : :
: : : exec('nmap'); #calls nmap
: : : print "domain name: " #asks for domain name
: : : $dom = ; #gets domain name
: : :
: : : How can i get the domain into the program nmap
: : :
: : : Help is greatly appreciated
: : :
: :
: :
:
:
I tried both www.yahoo.com and 127.0.0.1 and worked just fine.
: Ok i already tried everything u just told me and none of them work. Says failed to source address, try dottted decimal ip addy
:
: Theres a way just cant figure it out
:
: : Okay I may of misunderstood.
: :
: : I did it one way for you now let me do another way.
: : Below, will work if you just need to call nmap.
: : If you want your program to work w. nmap you can also
: : do the following.
: : Being that you are using the exec nmap Im assuming you are in
: : a Unix/linux OS.
: :
: : One thing you can do is export the perl vars into your shell.
: : That way for instance you can just use nmap and call shell variables.
: :
: : $host=;
: : chomp($host);
: : system("export PERLSCRIPTVAR="$host"");
: : #then to call it just use nmap $PERLSCRIPTVAR
: :
: : Hope these two explanations help.
: :
: :
: :
: : : Okay first off that is not making the program nmap simpler to use. If anything its making it more time consuming.
: : : However you do not want to exec it.
: : : Just do the following.
: : :
: : : print "Enter in hostname";
: : : $host=;
: : : chomp($host);
: : : system("nmap $host");
: : : print "
Done
";
: : :
: : :
: : :
: : : : OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
: : : :
: : : : exec('nmap'); #calls nmap
: : : : print "domain name: " #asks for domain name
: : : : $dom = ; #gets domain name
: : : :
: : : : How can i get the domain into the program nmap
: : : :
: : : : Help is greatly appreciated
: : : :
: : :
: : :
: :
: :
:
:
: hmm, I cannot try the second one being Im on a windows box however, the first one works fine for me.
: I tried both www.yahoo.com and 127.0.0.1 and worked just fine.
:
:
:
: : Ok i already tried everything u just told me and none of them work. Says failed to source address, try dottted decimal ip addy
: :
: : Theres a way just cant figure it out
: :
: : : Okay I may of misunderstood.
: : :
: : : I did it one way for you now let me do another way.
: : : Below, will work if you just need to call nmap.
: : : If you want your program to work w. nmap you can also
: : : do the following.
: : : Being that you are using the exec nmap Im assuming you are in
: : : a Unix/linux OS.
: : :
: : : One thing you can do is export the perl vars into your shell.
: : : That way for instance you can just use nmap and call shell variables.
: : :
: : : $host=;
: : : chomp($host);
: : : system("export PERLSCRIPTVAR="$host"");
: : : #then to call it just use nmap $PERLSCRIPTVAR
: : :
: : : Hope these two explanations help.
: : :
: : :
: : :
: : : : Okay first off that is not making the program nmap simpler to use. If anything its making it more time consuming.
: : : : However you do not want to exec it.
: : : : Just do the following.
: : : :
: : : : print "Enter in hostname";
: : : : $host=;
: : : : chomp($host);
: : : : system("nmap $host");
: : : : print "
Done
";
: : : :
: : : :
: : : :
: : : : : OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
: : : : :
: : : : : exec('nmap'); #calls nmap
: : : : : print "domain name: " #asks for domain name
: : : : : $dom = ; #gets domain name
: : : : :
: : : : : How can i get the domain into the program nmap
: : : : :
: : : : : Help is greatly appreciated
: : : : :
: : : :
: : : :
: : :
: : :
: :
: :
:
:
From what I remember you can make use of the backtick operator
eg:-
$MAPPATH = "/bin/nmap";
$OPTIONS = "whatever goes here";
$COMMAND = `$NMAPPATH -$OPTIONS $IP` #not sure about nmap options
chomp($IP = );
print $COMMAND;
This is just an example.
If i am not wrong that should simplify the process. I sincerely advise you not to use system excessively :-).
I don't see the point of exporting to make it available as a shell variable.
: Welp i can't figure it out. Really making me mad cus i know it should work.
: : hmm, I cannot try the second one being Im on a windows box however, the first one works fine for me.
: : I tried both www.yahoo.com and 127.0.0.1 and worked just fine.
: :
: :
: :
: : : Ok i already tried everything u just told me and none of them work. Says failed to source address, try dottted decimal ip addy
: : :
: : : Theres a way just cant figure it out
: : :
: : : : Okay I may of misunderstood.
: : : :
: : : : I did it one way for you now let me do another way.
: : : : Below, will work if you just need to call nmap.
: : : : If you want your program to work w. nmap you can also
: : : : do the following.
: : : : Being that you are using the exec nmap Im assuming you are in
: : : : a Unix/linux OS.
: : : :
: : : : One thing you can do is export the perl vars into your shell.
: : : : That way for instance you can just use nmap and call shell variables.
: : : :
: : : : $host=;
: : : : chomp($host);
: : : : system("export PERLSCRIPTVAR="$host"");
: : : : #then to call it just use nmap $PERLSCRIPTVAR
: : : :
: : : : Hope these two explanations help.
: : : :
: : : :
: : : :
: : : : : Okay first off that is not making the program nmap simpler to use. If anything its making it more time consuming.
: : : : : However you do not want to exec it.
: : : : : Just do the following.
: : : : :
: : : : : print "Enter in hostname";
: : : : : $host=;
: : : : : chomp($host);
: : : : : system("nmap $host");
: : : : : print "
Done
";
: : : : :
: : : : :
: : : : :
: : : : : : OK i want to make a program that makes some commands a little easier to use. For example i want to call nmap heres a snippet of my code
: : : : : :
: : : : : : exec('nmap'); #calls nmap
: : : : : : print "domain name: " #asks for domain name
: : : : : : $dom = ; #gets domain name
: : : : : :
: : : : : : How can i get the domain into the program nmap
: : : : : :
: : : : : : Help is greatly appreciated
: : : : : :
: : : : :
: : : : :
: : : :
: : : :
: : :
: : :
: :
: :
:
:
Are you on a *nix system? If so, then using perl for this is
excessive. A simple shell script will do exactly what you need,
without the overhead of the perl interpreter loading.
[code]
#!/bin/bash
echo -n "Please enter a host: "
read HOST
nmap $HOST
[/code]
TheLinuxDuck
"Truely you have a dizzying intellect" - The Princess Bride
Yes i am on a nix system and none of that worked
: ocYrus:
:
: Are you on a *nix system? If so, then using perl for this is
: excessive. A simple shell script will do exactly what you need,
: without the overhead of the perl interpreter loading.
:
: [code]
: #!/bin/bash
:
: echo -n "Please enter a host: "
: read HOST
: nmap $HOST
: [/code]
: TheLinuxDuck
: "Truely you have a dizzying intellect" - The Princess Bride
:
:
The script worked fine on my system. The only logical conclusion
is that something is not set up correctly on your system (that
this usage requires). Let's start from the beginning.
What are the scripts contents? Did you make it executable?
Then, does nmap run from the command line? Is it in your path?
What output do you get when you run it as:
[code]
nmap 127.0.0.1
[/code]
If that works, then let's assign that IP to a variable, and
call nmap with the variable to make sure it is working right.
[code]
~> export IP="127.0.0.1"
~> echo "$IP"
127.0.0.1
~> nmap $IP
[/code]
If that works, then make sure that the path to bash is correct,
by:
[code]
which bash
[/code]
If the return path matches, then let's make sure that the read
command is working correctly. From the command line, run this
read command, and enter the 127.0.0.1 IP, as:
[code]
~>read IP
127.0.0.1[enter]
~> echo "$IP"
127.0.0.1
[/code]
If that works then the problem is with the script itself. What
does the script contain? What error message does it return
when you run it?
TheLinuxDuck
"Truely you have a dizzying intellect" - The Princess Bride