Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Why Don't My Scripts Run?
cagey cretin
post Dec 28 2003, 07:27 AM
Post #1


./configure
***

Group: Members
Posts: 96
Joined: 9-September 03
Member No.: 1,413



In my trials of trying to get a mailserver working, I have had to do clean installs of Redhat 9 enough times that I decided to write a few scripts to copy data files /folders from a CD, create directories, chmod & chown other directories.

These scripts worked fine when I wrote them (I put them in the 'scripts' folder), and then I burned them onto a data CD so that I wouldn't have to write them each time I installed. However, when I tried them on a fresh install (run from the 'scripts' folder), nothing happened. unsure.gif I mean, the computer looked like it had HD activity, the CD rom had activity, and then nothing. dry.gif

This is really frustrating. It seems so counter-productive to not really know if something is going to work or not, and really defeats the whole purpose of trying to automate processes.
Go to the top of the page
 
+Quote Post
hughesjr
post Dec 28 2003, 08:29 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



I use scripts to do many things ... so scripts work biggrin.gif

The problem with scripts is this:

They do exactly what we TELL them to do ... not what we WANT them to do wink.gif
---------------
Some pointers (that I learned the hard way) are:

1. Either include the full path to your executable (/bin/ls instead of ls, for example) ... or include a PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin near the top of the file.

2. Always include a pointer as the first line of the file that points to the correct shell to run the program:

examples:

#!/bin/sh
#!/bin/bash
#!/bin/tcsh


3. Make sure to set you environment variables in the script (especially if running from a cron ... root runs all crons and in a shell that DOESN'T have root's envronment. For example, if you want root's environment (in a bash script) then use the command:

source /root/.bash_profile

in the script.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
cagey cretin
post Dec 28 2003, 09:02 AM
Post #3


./configure
***

Group: Members
Posts: 96
Joined: 9-September 03
Member No.: 1,413



Thanks HughesJR. I tried your suggestion, but with no joy.

CODE
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
source /root/.bash_profile


It seems so illogical that the script that I wrote and tested (yeah, it worked fine) won't work after a new clean install. I swear to God I think people went out of their way to obfuscate how to set up a linux system!!!! (Not you, Not you!!!) It makes zero sense to me; I cannot see how it shouldn't have worked when it did earlier!!!!! GD it I hate this ####!!!!

mad.gif
Go to the top of the page
 
+Quote Post
hughesjr
post Dec 28 2003, 10:14 AM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



if you post your script(s) I'll be glad to take a look at them and see if I can help.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
cagey cretin
post Dec 28 2003, 10:45 AM
Post #5


./configure
***

Group: Members
Posts: 96
Joined: 9-September 03
Member No.: 1,413



Thanks...

CODE
#!/bin/bash
source /root/.bash_profile
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin near
cp -R /mnt/cdrom/docs  /root/.gnome-desktop
cp -R /mnt/cdrom/Qmail /root/.gnome-desktop
cp -R /mnt/cdrom/web /root/.gnome-desktop
cp -R /mnt/cdrom/conf /root/.gnome-desktop
cp -R /mnt/cdrom/scripts /root/.gnome-desktop
cp -R /mnt/cdrom/index.html /root/.gnome-desktop
cp /root/.gnome-desktop/scripts/SCRIPT_3_NEW_USERS /root/.gnome2/nautilus-scripts
cp /root/.gnome-desktop/scripts/SCRIPT_Services_HTTPD_VSFTPD /root/.gnome2/nautilus-scripts
Go to the top of the page
 
+Quote Post
hughesjr
post Dec 28 2003, 11:53 PM
Post #6


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



I don't see anything wrong with the scripts ... was your CDROM mounted?
------------------
as a side note ... add this to the top of the script (between PATH and the first copy statement) and it will mount the CD if it is in the drive but not mounted:

CODE
mounted=`mount | grep cdrom`
if [ "$mounted"x == "x" ]; then
 #not mounted
  mount /dev/cdrom
fi


{BTW, the ` is the key under ~ (to the left of the number 1) and not a single quote...items inside a `` are run and the result placed in the script}
------------------


another potential issue is that the desktop location is changed in gnome 2.4 ... it is no longer in .gnome_desktop, but at Desktop in the user's home directory. RedHat 9 has gnome 2.2 but there are places that you can upgrade to 2.4 ... the command:

rpm -q gnome-desktop

should give you your version if you aren't sure which you have...


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
cagey cretin
post Dec 29 2003, 10:51 AM
Post #7


./configure
***

Group: Members
Posts: 96
Joined: 9-September 03
Member No.: 1,413



I really appreciate your time HughesJr. Thank you. smile.gif

The CD was mounted. I ran the script again and there is no activity at all. None whatsoever. I put in the 'mount CD ROM' code you provided, but there is still no activity. There must be something not set up right with Redhat 9 on my PC, so I am just going to forget it and cut and paste the text in a terminal screen.

Thank you again, and warmest regards,

Joe
Go to the top of the page
 
+Quote Post
cagey cretin
post Dec 30 2003, 10:31 AM
Post #8


./configure
***

Group: Members
Posts: 96
Joined: 9-September 03
Member No.: 1,413



Thanks for trying Hughesjr. I wanted to give you closure (in that your info was right, but that I had bad dope on this end).

Let it be known that not any text editor within linux can create a script file. I opened up my script in vi and found extra characters at the end of each line that Redhats GNU gedit put there. I spent $50 for a big yellow 'Redhat 9 Bible' published by Hungry Minds. I swear, I own 5 or 6 books from them, and they have misleading information in all of them. They told me that any text editor will do just fine.

Beware!

CC
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd October 2017 - 09:23 PM