Hi All,

I am trying to create a bash script (partly for my own learning to be fair), that runs nmap against a remote machine, but I am getting an error I can't understand.

This is my nascent bash script:

Code:
#!/usr/bin/bash


CheckIfResponding() {

    echo $2
    echo $3

    bRunningHTTPS1=$(`/usr/bin/nmap $2 -PN -p $3`)

    echo $bRunningHTTPS1

    }



CheckIfResponding TestMachine 10.2.1.5 443
It errors with the following:

ZZ_Test.sh: line 9: Starting: command not found

Line 9 being:

Code:
bRunningHTTPS1=$(`/usr/bin/nmap $2 -PN -p $3`)
The echos are me trying to debug so I know I am passing the correct parameters. They correctly return:

10.2.1.5
80

If I try running this on the command line it works fine:

Code:
$ /usr/bin/nmap 10.2.1.5 -PN -p 443

Starting Nmap 7.80 ( https://nmap.org ) at 2023-09-12 21:30 NZST
Nmap scan report for 10.2.1.5
Host is up

PORT      STATE SERVICE
443/tcp filtered  https

Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds

I am thrown by the result 'Command not found' which appears to be saying that 'nmap' is not found, but clearly it is 'found' and installed, else the interactive command would fail?


Thanks in advance for any pointers you can provide.

Alan.