Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| 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. |
|
 |
06-07-2004, 01:54 PM
|
#1
|
|
Member
Registered: Sep 2003
Distribution: Mandriva 2006,OpenSuse 10.1
Posts: 154
Rep:
|
BASH Scripting ?
Hello,
I'm a newbie to Linux and am trying to write a small shell script to start squid cache server and then mozilla. it looks like this:
#!/bin/bash
/etc/init.d/squid restart &
/usr/local/mozilla/mozilla
the problem I have is I want to run it from Desktop as a shortcut and just click it and have it run. When I do this the squid service does not restart and then mozilla starts and says proxy not running. If I run it from command line as root the script runs fine. So i have to assume there are some rights issue when using the shortcut. I tried giving the squid binary executable rights to my user but that did not help. Is there someway to run the squid script as root from my script. Any suggestions people.thanx
alan
|
|
|
|
06-07-2004, 02:32 PM
|
#2
|
|
Senior Member
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142
Rep:
|
Well, I can get it to work, but I don't really like the process...
Change the squid line to "su -c '/sbin/service squid restart'".
Then, right-click the desktop link you are using to run the script, and choose Properties, Application, Advanced Options. Set the link to run in a terminal.
Now, when you run the link, it will open a terminal, and ask for the root password. If you give it the correct password, it will run restart squid. If you give it the wrong password, it won't. Either way, it will then start Mozilla.
The part I don't like is that if somebody can get into your script, they can put something malicious in the su command, and you would run it not knowing. I would just open a terminal and type in the su command when I needed to.
|
|
|
|
06-07-2004, 02:53 PM
|
#3
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
Jost poking in here... Why is it necessary to have the squid restart execute in the background (the &)? I would guess that's part of the problem. The shell fires off the command and proceeds immediately to start up mozilla (whether the squid restart has finished or not). I would bet mozilla is just starting up faster than squid can take care of its restart (but I've been wrong before).
My suggesstion: cut out the '&' entirely, or change it to '&&'. With the '&&', mozilla won't start unless the return value of the squid restart indicated success (and it shouldn't return a value until the restart is finished).
|
|
|
|
06-07-2004, 07:51 PM
|
#4
|
|
Member
Registered: Sep 2003
Distribution: Mandriva 2006,OpenSuse 10.1
Posts: 154
Original Poster
Rep:
|
hello,
thanx 4 the advice i'll try it . The problem is actually w/squid if anyone is familiar w/this program. the service is not startting up @ boot. I have it running @ work on system w/a dialup modem. Examining the logs I see squid is looking for a dns server @ bootup and obviously it dosent find one. The squid service thus stops after several attemepts and is not running when I begin my computing session. I then have to get a root console and issue /etc/init.d/squid restart command. I was thus trying to get a quick script going so I could get mozilla up w/one click. but u bring out a good point about security problem w/this approach. Does anyone know of a good place to ask ?'s abou t squid configuration problems. I tried squid.org but they dont have any forums and queries to their bugzilla database yielded nothing...
alan
|
|
|
|
| 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 12:57 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
|
|