Help with opening webpage with IP#


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with opening webpage with IP#
# 1  
Old 05-26-2011
Bug Help with opening webpage with IP#

Hi,
I would like to open a webpage from an IP# from a file.

Lets say I findout an IP address from using grep
grep John remotecomputers.txt

result: 192.168.2.1

Then after that I would like to increment the IP# to 192.168.2.2 from 192.168.2.1

After that I woud like to launch mozilla or a browser to open up his webpage.

I need help with writing the rest of the script from storing 192.168.2.1 to incremnting it by 1. Then storing it.

Please help, many thanks!
# 2  
Old 05-26-2011
Small script. Don't know if invoking firefox this way will do what you want; play with it if it doesn't.

Code:
#!/usr/bin/env ksh

grep John remotecomputers.txt | head - 1 | read junk ip junk   
nxt_ip="${ip%.*}.$(( ${ip##*.} + 1 ))"

firefox "http://$ip"
firefox "http://$nxt_ip"

The "shell magic":
Code:
${ip%.*}  # delete the shortest string .* from the contents of the variable as it is expanded
${ip##*.}  # delete the longest string *.  from the contents of the variable as it is expanded
$((  expr ))   # compute the expression in the double parens

The code assumes that the lines in the input file have the IP address as the second token, something like:
Code:
John 192.16.18.1  some comments or junk

It will also only use the first line that matches in the input file.
This User Gave Thanks to agama For This Post:
# 3  
Old 05-26-2011
I thought thought it would be very simple to a guru.

I just finished my script using the cut and echo command.
It me about 15 line of codes and about 2 hours :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to open webpage through UNIX?

Hi friends, I have UNIX (HP-UX) server. I want to open a webpage (lets say www.unixhelp.com) on this webpage there is one checkbox. I just need to check it. and click on save. Its just take a half a minute to do so in windows system. But I am wondering if this is possible though UNIX server.... (3 Replies)
Discussion started by: Nakul_sh
3 Replies

2. Solaris

Webpage Display

Hi, I need to display the output of a script in web page. Can anyone suggest me how to do that? (5 Replies)
Discussion started by: Arasu
5 Replies

3. Shell Programming and Scripting

Nagios chomping webpage

Hello Gurus Am facing situation to chomp webpage and get the values from in it and that value need to monitor by nagios . could you advise me how i can achieve this task . Thanks (1 Reply)
Discussion started by: Salim_Linux
1 Replies

4. UNIX for Dummies Questions & Answers

Access Webpage in UNIX

Dear All, I do not know anything from UNIX and its systems. I have a course on bioinformatics and they taught us a little about the UNIX. They also provided a userID and password for the web server which I can access using SSH. now, with A LOT OF EFFORT, I wrote a small index.html file, saved it... (1 Reply)
Discussion started by: dreamer0085
1 Replies

5. UNIX for Dummies Questions & Answers

how do I connect my crontab with a webpage

I crontab a file name foo containing 0,15 * * * * quota -v cs9e-1bp now I have to connect the crontab to http://inst.eecs.berkeley.edu/~cs9e-1bp/disk_usage.txt and make the webpage accessible to all the users. I make a directory disk_usage.txt in my account cs9e-1bp, now how do I connect the... (1 Reply)
Discussion started by: JJSSKK
1 Replies

6. Shell Programming and Scripting

Run a script from a webpage

Hello, I was trying to run a shell script when I click on webpage link. My webpage is hosted on Sun One web server. This is something I was looking, Chris Johnson's Test Bed I already have my shell script and it works fine when I run it from the command line. Can somebody tell me what are... (3 Replies)
Discussion started by: grajp002
3 Replies

7. Linux

use of FTP in webpage

Please help me to start with this trek... What are the steps for me to implement at FTP functionality on my web page... we have a linux box as our proxy server... (0 Replies)
Discussion started by: shiny
0 Replies

8. IP Networking

Where is the Default Webpage

I have SCO OpenServer 5 connected to the Internet and I would like to change the webpage that appears when I try from another computer the address: http://192.1xx.xx.xx. If I try this, a page about SCO appears, but I don't know where can I find it. Thanks:cool: (1 Reply)
Discussion started by: SuPeRbYtE
1 Replies

9. UNIX for Dummies Questions & Answers

webpage

Hi I was wondering how do I make my own webpage??? :rolleyes::confused: (4 Replies)
Discussion started by: babysoft19
4 Replies
Login or Register to Ask a Question