#!/usr/local/bin/perl ################################################################## # ipinrc ############################################################### ############### Determines the terminals neighbours ########### $INPUT_FILE="/home/auto/terminalip"; open(INPUT_FILE); $ipterm=; close(INPUT_FILE); print("$ipterm\n"); #gives the substring after the last decimal $position=rindex("$ipterm",".")+1; $tochange=substr($ipterm,$position); #print("$tochange\n"); print ("The expected adjacent nodes are:\n"); $firstchange=$tochange+1; $firstip="192.168.0.$firstchange"; print("$firstip\n"); $secondchange=$tochange-1; $secondip="192.168.0.$secondchange"; print("$secondip\n"); $thirdchange=$tochange+4; $thirdip="192.168.0.$thirdchange"; print("$thirdip\n"); $fourthchange=$tochange-4; $fourthip="192.168.0.$fourthchange"; print("$fourthip\n"); #write these ips in files open(LOGFILE,">/home/admin/ip1"); print LOGFILE ("$firstip\n"); close (LOGFILE); open(LOGFILE,">/home/admin/ip2"); print LOGFILE ("$secondip\n"); close (LOGFILE); open(LOGFILE,">/home/admin/ip3"); print LOGFILE ("$thirdip\n"); close(LOGFILE); open(LOGFILE,">/home/admin/ip4"); print LOGFILE ("$fourthip\n"); close(LOGFILE);