I need to run one script from several machines but each machine requires unique commands to be executed.
I thought that a bash script would be able to do this but I’m not too savvy in this department.
The code I require would look similar to the below code (or would it). I know that it’s far from perfect or functional but it’s really there just to help to express what I am looking for.
Could somebody please help me with this script?
#/bin/bash
IP= ifconfig eth0 | grep inet | grep -v inet6 | cut -c 7-17
If [$IP -eq 192.168.32.1]
then mkdir IPFolder-1
more code...
else
if [$IP -eq 192.168.32.2]
then mkdir IPFolder-2
more code...
else
if [$IP -eq 192.168.32.5]
then mkdir IPFolder-5
more code...
use double brackets, spaces are important:
Note: on Ubuntu 11.10, I had to use cut -c 21-34, adapt as necessary.