#!/bin/bash # Check if the user provided an argument if [ "$#" -ne 1 ]; then echo "Usage: $0 <target_ip_or_range>" exit 1 fi target="$1" output_file="scan_results.txt" # Run nmap scan echo "Starting scan on $target..." nmap -sS -sV -O "$target" -oN "$output_file" # Check if the scan was successful if [ $? -eq 0 ]; then echo "Scan completed successfully. Results saved to $output_file." else echo "Scan failed." fi