LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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



Reply
 
Search this Thread
Old 06-07-2004, 02:54 PM   #1
eroica
Member
 
Registered: Sep 2003
Distribution: Mandriva 2006,OpenSuse 10.1
Posts: 154

Rep: Reputation: 30
Question 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
 
Old 06-07-2004, 03:32 PM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
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.
 
Old 06-07-2004, 03:53 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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).
 
Old 06-07-2004, 08:51 PM   #4
eroica
Member
 
Registered: Sep 2003
Distribution: Mandriva 2006,OpenSuse 10.1
Posts: 154

Original Poster
Rep: Reputation: 30
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
 
  


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
Bash scripting help (su ...) shwong Linux - General 1 11-02-2005 01:26 PM
Bash scripting pete1234 Programming 1 09-27-2005 02:48 AM
bash scripting vadon Linux - Newbie 6 05-10-2005 05:07 AM
need help with bash scripting rich2oo1 Programming 2 12-17-2003 01:50 PM
HELP with BASH scripting atwah Linux - Newbie 6 09-09-2003 02:10 AM


All times are GMT -5. The time now is 10:24 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