#!/bin/bash
echo "Dollars0 = $0"
echo "Dollars1 = $1"
chmod a+x scriptname
#!/bin/bash
if [ "$1" == "" ]
then
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 192.168.10"
else
for x in `seq 1 254`; do
ping -c 1 $1.$x
done
fi
Note: the back-tick character ` is the key
below Esc, near the top left of the
keyboard.
#!/bin/bash
if [ "$1" == "" ]
then
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 192.168.10"
else
for x in `seq 1 254`; do
ping -c 1 $1.$x | grep "64 bytes" | cut -d " " -f 4 | sed 's/.$//'
done
fi
#!/usr/bin/python
import socket
ip = raw_input("Enter the ip: ")
port = int(raw_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"
#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);
}
}
Compile and run
gcc hello.c -o hello
./hello