Sponsored Content
Full Discussion: Running nmap via bash script
Top Forums Shell Programming and Scripting Running nmap via bash script Post 303026043 by hawkeyesc72 on Monday 19th of November 2018 02:00:34 AM
Old 11-19-2018
Here's my script:

Code:
!/bin/bash
NETWORKS='çat networks.txt'
for NETWORK in $NETWORKS
     nmap -sn -oN /root/Desktop/$NETWORK
done
echo "Finished!"

The networks.txt file has my list of network addresses I want to scan. If I enter a single IP address, like 1.2.3.4, the script works fine and the outpu file is named 1.2.3.4.nmap. But when I enter a network address, like 1.2.3.0/24, script errors off saying it cannot open file /root/Desktop/1.2.3.0/24 for writing. This error tells me the script is at least SEEING the right information in the txt file it's just not processing it properly. If I put single ' marks around $NETWORK so that it reads /root/Desktop/'$NETWORK' the script runs and the output file name is $NETWORK and not 1.2.3.0/24.

Is there a way to associate each network address by a number instead of a name and reference that number? Like:

Code:
#1   1.2.3.0/24
#2   2.3.4.0/24

So I would code the script to take the network address and save it in a file name by its associated number (#1.nmap, #2.nmap, etc.)

Thanks!
 

10 More Discussions You Might Find Interesting

1. Linux

Cannot running export database using bash script

Hi all, I'm new in linux. When I try to run a bash script, it doesn't execute and i receive the following error message 20070321:220002|ERROR||exportDatabase.bash|Another EXPORT process (pid=2799) is still running. If i kill this pid, i receive "No such process". This process was running... (5 Replies)
Discussion started by: tovohery
5 Replies

2. UNIX for Advanced & Expert Users

debugging an already running bash script

# ps -ef | grep rc root 13903 1 0 08:56 ? 00:00:00 /usr/sbin/automount --timeout=60 /archive file /etc/auto_archive root 10706 1 0 08:55 ? 00:00:00 /bin/bash /etc/rc.d/rc 3 root 2933 20071 0 19:38 pts/1 00:00:00 grep rc Is there any way to debug the... (1 Reply)
Discussion started by: marcpascual
1 Replies

3. Shell Programming and Scripting

Script running in bash 3.0 not in 3.2

I have wasted one working day writing this scripts. It compares two folders and make a good tabbed report about their differences. #!/bin/bash function DRAW_DEPTH () { ROUND=$1 while do printf %s " " ROUND=`expr $ROUND - 1` done printf %s "|- " } function MAIN () {... (9 Replies)
Discussion started by: trutoman
9 Replies

4. Shell Programming and Scripting

Validate BASH script before running it...

Hello, Is there some way to validate a bash script before running it. I want to make sure all of the syntax and everything is good so that I dont get a false return code. Thanks, tom (7 Replies)
Discussion started by: tjones1105
7 Replies

5. UNIX for Dummies Questions & Answers

Running Executable in Bash Script

Hey guys, so I've been trying to write a bash script called runSorter.sh that runs an executable that also takes in some parameters and outputs the results to a text file. The executable, sorter, takes in a number parameter. I want to make it so that you can input as many number parameters into... (4 Replies)
Discussion started by: Duo11
4 Replies

6. UNIX for Dummies Questions & Answers

Help Running a Check in Bash Script

Hey guys, so I wrote a small script that pretty much just takes in two numbers and counts from the first to the second, e.g. unknown-hacker|544> count.sh 1 3 1 2 3 My problem is I want to make it so that if you input invalid parameters, such as non-numerical characters, more than 2... (2 Replies)
Discussion started by: Duo11
2 Replies

7. Shell Programming and Scripting

bash script to check if a program is running

I'm a bit new to bash programming and I was assigned the job of writing a script that will check to see if a program server is running and to restart the program if it is not up. The script is supposed to check the program every hour (which I have looked up and I believe I know how to do) and send... (3 Replies)
Discussion started by: mcknz
3 Replies

8. Shell Programming and Scripting

script running by sh but not by bash

execute the attached script as, bash -x INFA_MAP_GEN_XML.sh "/export/home/e120945/INFORMATICA_MAPPING_GENERATOR/SOURCE" "INFA_TEMPLATE.csv" "/export/home/e120945/INFORMATICA_MAPPING_GENERATOR/TARGET" "UNIX" "/export/home/e120945/INFORMATICA_MAPPING_GENERATOR/SETUP"... (5 Replies)
Discussion started by: 120945
5 Replies

9. Shell Programming and Scripting

Bash shell script to check if script itself is running

hi guys we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Discussion started by: hedkandi
8 Replies

10. Shell Programming and Scripting

Running options in bash script

Hello UNIX & Linux Forums community! Long time Linux daily user hobbyist, new to shell scripting.... I'm working on a script that does all the "work" in one script, and makes calls to a second script to display info to the user via mostly expanding variables in heredocs. I'm contemplating... (6 Replies)
Discussion started by: Cody Learner
6 Replies
PCT-SCANNER-SCRIPT(1)					      General Commands Manual					     PCT-SCANNER-SCRIPT(1)

NAME
pct-scanner-script - easy scan and create merged DjVu and PDF documents for archiving SYNOPSIS
pct-scanner-script [--help] DESCRIPTION
pct-scanner-script is a bash script and configuration system to easily scan documents and create a digital archiving. It can create DjVu PDF and JPEG outputs, in merged and individual files. It also has a configuration system where different configurations can be defined, making it easy to switch between configurations. Please use pct-scanner-script --help to find all program options, the complete help, and all examples. Features: - auto archiving in merged and individual DjVu, PDF, and JPEG files - auto and manual resume when scanning somehow fails - cascading configuration system, for easy customizing - easy command-line-style bash program, with useful options - archiving made possible with both adf and flatbed scanners - built for productivity and daily use - uses bash, scanadf and other mainstream processing tools - multilanguage commandline output OPTIONS
-h, --help, -? Show summary of options, help, and examples. DEBUGGING
This program is a helper script to easy scan and automated digital document archiving for normal and adf scanners. You can debug this script by running it as bash -x pct-scanner-script [options]. The script is just a nice wrapper for the scanadf, DjVu and PDF tools. SEE ALSO
scanadf(1), AUTHOR
pct-scanner-script and this manual page are written by: Jelle de Jong <jelledejong@powercraft.nl>. March 31, 2009 PCT-SCANNER-SCRIPT(1)
All times are GMT -4. The time now is 03:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy