Help needed for simple IP reset script
Hello,
Alright so I am more of a Windows guy still trying to learn Linux. I need to create a simple script to reset the IP and check it. These are what I was hoping to run, just when I tried to create my own script, it fails. I know this is not right but I was trying, can someone can please help me with creating this properly. I was wondering if it is also possible just to display an IFCONFIG on eth0? Code:
#!/bin/bash |
You don't need to call echo in front of ifconfig.
Just run ifconfig and it presents it output magicaly ;) What are you trying to achive? Comparing the two outputs before and after? Just a little hint. GEt familiar with the ip command. It's the new way of doing things. |
Okay, sorry I should of explained a little better.
It's a little Eee PC machine I use for work to test connectivity through ports and firewalls at remote sites. However I did not originally set up the machines so not everything that we would like is installed. Example, vi will not open an editor, had to use gedit. They were given static addresses to connect through a 3002 VPN. Some locations like Hotels do not allow you access until you accept their TOA. Now I had to manually do this with a customer and it was annoying to constantly have him type and hit the Up arrow for commands. So I changed it to DHCP but I need to be able to reset the IP of eth0 between a privately given IP from the hotel and the one the 3002 VPN wants to give it (172.31.1.2). I would also like to try and display the IP so that we can confirm what it is currently at. It's difficult to try and correct this when I am unsure of what I am doing still. I did try at first without the Echo but I failed to even see a terminal appear or anything. |
Okay. First thing is that linux is case sensitive. As you have Echo in your line 4 which gives
Code:
./trial.sh: line 4: Echo: command not found Another thing is that you don't need to use echo in front of commands they print what they print to the output. echo is for output of message for the user like Code:
echo 'Restarting network' |
Okay, So the only thing I am having an issue with is trying to print this for the user to see what is going on. It happens in a flash and I remember how to do it in a batch file but not a shell script
Code:
#!/bin/bash I want to thank you for the taking the time to help me with this. I know its trivial for you but it is also what makes me want to get into linux when I know people are willing to help through all the entry level questions. |
Try this one
Code:
#!/bin/bash grep searches for a string. I guess you only want the ip address awk is for printing stuff nice and other things. We want the second field which holds the ip. read just waits for input. This makes sure the window stays open. You get the ipv4 as well as the ipv6 address. Suite to your likings. Quote:
If you feel so you can click the "Was that post helpfull" to fill my karma a bit. |
All times are GMT -5. The time now is 09:55 PM. |