Left off at
Page 80 (Chapter 3)
Chapter 3
Simple Bash Script
#!/bin/bash
if [ "$1" == "" ]
then
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 172.16.56.2"
else
for x in `seq 1 254`; do
ping -c 1 $1.$x | grep "64 bytes" | cut -d" " -f4 | sed 's/.$//'
done
fi
Simple Python Script
#!/usr/bin/python
import socket
ip = raw_input("Enter the ip: ")
port = input("Enter the port: ")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if s.connect_ex((ip, port)):
print "Port", port, "is closed"
else:
print "Port", port, "is open"
Simple C Script
#include <stdio.h>
int main(int argc, char *argv[])
{
if(argc < 2)
{
printf("%s\n", "Pass your name as an argument");
return 0;
}
else
{
printf("Hello %s\n", argv[1]);
return 0;
}
}