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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
04-25-2003, 07:52 AM
|
#1
|
|
LQ Newbie
Registered: Apr 2003
Location: Rockville, MD
Posts: 9
Rep:
|
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?
|
|
|
|
04-25-2003, 12:01 PM
|
#2
|
|
Member
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290
Rep:
|
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 "
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
|
|
|
|
04-25-2003, 12:23 PM
|
#3
|
|
LQ Newbie
Registered: Apr 2003
Location: Rockville, MD
Posts: 9
Original Poster
Rep:
|
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 
|
|
|
|
04-25-2003, 02:05 PM
|
#4
|
|
Member
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290
Rep:
|
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!
|
|
|
|
04-25-2003, 02:09 PM
|
#5
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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
|
|
|
|
04-25-2003, 02:11 PM
|
#6
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
As for the kill part - just extract the PID from "ps -ef" then "kill -9 MOZILLAsPID".
|
|
|
|
04-25-2003, 02:20 PM
|
#7
|
|
LQ Newbie
Registered: Apr 2003
Location: Rockville, MD
Posts: 9
Original Poster
Rep:
|
How could I get all of this to run automatically without me typing in the commands?
|
|
|
|
04-25-2003, 02:29 PM
|
#8
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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.
|
|
|
|
04-25-2003, 02:30 PM
|
#9
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
PS the -dump returns the output with the HTML removed so you can send the output to a file for logging purposes.
|
|
|
|
04-25-2003, 02:41 PM
|
#10
|
|
Member
Registered: Apr 2003
Distribution: Gentoo 1.4
Posts: 290
Rep:
|
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?
|
|
|
|
04-25-2003, 02:41 PM
|
#11
|
|
LQ Newbie
Registered: Apr 2003
Location: Rockville, MD
Posts: 9
Original Poster
Rep:
|
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?
|
|
|
|
04-25-2003, 04:53 PM
|
#12
|
|
Senior Member
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120
Rep:
|
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 
|
|
|
|
04-26-2003, 10:55 AM
|
#13
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
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
|
|
|
|
04-28-2003, 08:28 AM
|
#14
|
|
LQ Newbie
Registered: Apr 2003
Location: Rockville, MD
Posts: 9
Original Poster
Rep:
|
Thanks all!!! Everything is working great. You guys saved my butt 
|
|
|
|
04-28-2003, 08:41 AM
|
#15
|
|
Guru
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565
Rep:
|
What are you trying to do exactly? Find out when a website fails?
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:38 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|