LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 04-25-2003, 08:52 AM   #1
ArosemenaA
LQ Newbie
 
Registered: Apr 2003
Location: Rockville, MD
Posts: 9

Rep: Reputation: 0
Exclamation RedHat 9 Script to open and close Mozilla?


Does anyone know how to create a script using VI to open mozilla, go to a url, then close the browser after it's finished loading?
 
Old 04-25-2003, 01:01 PM   #2
martinman
Member
 
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290

Rep: Reputation: 30
i got the open part for ya...i'm lost as to how to close it though, sorry

1. Open up a new terminal window
2. CD to the directory you want to save the shell script in
3. type "vi mozilla.sh" or whatever you want it to be called (must end in .sh)
4. Hit " I " to switch to insert mode
5. copy the following into the file
6. hit ESC
7. type " :wq " to save the file and quit
8. now, to run the script, just type " sh mozilla.sh "
Quote:
#!/bin/bash
#
#start mozilla and go directly to the url specified

mozilla -remote "openurl(http://www.somesite.com,new-window)"
closing will be much more difficult, at least for the newb like me. So for i know you hafta use " ps -ef | grep mozilla " ...thats about it
 
Old 04-25-2003, 01:23 PM   #3
ArosemenaA
LQ Newbie
 
Registered: Apr 2003
Location: Rockville, MD
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks a bunch for replying!! The open part gets the job done for now, and works. To close it, I though about somehow finding the process then killing it, but I'm not really sure how to go about that. Hopefully someone else will reply
 
Old 04-25-2003, 03:05 PM   #4
martinman
Member
 
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290

Rep: Reputation: 30
no problem, the close function can be done, rather easily too...i've seen an example of it, and tried to implement it in this case, but i'm just a newb too...so i plain and simply dont have the skills yet...o well, newbs rejoice!
 
Old 04-25-2003, 03:09 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
If you re just trying to access a url and not look at the result use wget or lynx. Is it similar to this thread:
http://www.linuxquestions.org/questi...808#post275808
 
Old 04-25-2003, 03:11 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
As for the kill part - just extract the PID from "ps -ef" then "kill -9 MOZILLAsPID".
 
Old 04-25-2003, 03:20 PM   #7
ArosemenaA
LQ Newbie
 
Registered: Apr 2003
Location: Rockville, MD
Posts: 9

Original Poster
Rep: Reputation: 0
How could I get all of this to run automatically without me typing in the commands?
 
Old 04-25-2003, 03:29 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
What are you trying to do?

Just access a page without you doing anything? Set:
lynx -dump http://www.myurl.com/mypage.html
to run as a cron job.
 
Old 04-25-2003, 03:30 PM   #9
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
PS the -dump returns the output with the HTML removed so you can send the output to a file for logging purposes.
 
Old 04-25-2003, 03:41 PM   #10
martinman
Member
 
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290

Rep: Reputation: 30
Quote:
Originally posted by david_ross
As for the kill part - just extract the PID from "ps -ef" then "kill -9 MOZILLAsPID".
well, yeah, even i could figure that out =P But whats the code for that?
 
Old 04-25-2003, 03:41 PM   #11
ArosemenaA
LQ Newbie
 
Registered: Apr 2003
Location: Rockville, MD
Posts: 9

Original Poster
Rep: Reputation: 0
Ok, I have it typed in like this under contab, but it doesn't run. It only runs if I type it in at the terminal.

15 * * * * root /var/scripts/open-browser.sh

Did I do something wrong here?
 
Old 04-25-2003, 05:53 PM   #12
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
mozilla http://www.yahoo.com &

sleep 5
output=`ps -C mozilla-bin`

pid=${output:28:6}
kill $pid

exit 0

I did this which does exactly what you asked for although that's all it does opens and closes the browser at the specified page. Not sure if it'll only work on my setup, Java is more my thing, and it's definitely not robust. I've only been looking at scripting for practically all of 2 minutes. 'Tis fun though
 
Old 04-26-2003, 11:55 AM   #13
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
What does the root command do?
15 * * * * root /var/scripts/open-browser.sh

shouldn't it just be:
15 * * * * /var/scripts/open-browser.sh

Then pu it in your crontab with:
crontab /path/to/cron.file

Then check it with:
crontab -l
 
Old 04-28-2003, 09:28 AM   #14
ArosemenaA
LQ Newbie
 
Registered: Apr 2003
Location: Rockville, MD
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks all!!! Everything is working great. You guys saved my butt
 
Old 04-28-2003, 09:41 AM   #15
mhearn
Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 47
What are you trying to do exactly? Find out when a website fails?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla Firefox open new window script Pathian Linux - Software 17 08-12-2004 01:37 PM
Mozilla (official) Open New Window script tuxq Linux - Software 1 08-10-2004 08:43 PM
Which ports should I keep open and which close?? apache Linux - Security 3 07-19-2004 09:31 AM
RedHat 9 - I cannot open a Mozilla web page Linh Red Hat 1 03-29-2004 02:03 PM
how to close open ports mayagenesis Linux - Networking 1 07-31-2003 01:47 AM


All times are GMT -5. The time now is 11:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration