I have a shell script that runs nmap on an address, and I want to have it do it daily for me. So I added a reference to it in my crontab.
Unfortunately, for some reason it doesn't recognize the arguments I'm sending to nmap. While it runs fine when I run it explicitly, it errors in cron on the first argument.
Cron entry:
0 3 * * * /home/directedition/observatory/nmapscan.sh # JOB_ID_1
Script:
#!/bin/bash
today=$(date +"%Y-%m-%d")
tempfilename=/home/directedition/observatory/scan-$today.temp.xml
filename=/home/directedition/observatory/scan-$today.xml
touch $tempfilename
chmod 640 $tempfilename
/usr/bin/nmap -A -T5 -O -v -oX $tempfilename 10.10.1.0-255 > /home/directedition/observatory/nmapoutput.txt
chown directedition $tempfilename
chmod 644 $tempfilename
mv $tempfilename $filename
Error: nmap: invalid option -- 'A'
I can shuffle the arguments around, and whichever I put first will invariably error.