LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-04-2005, 03:56 AM   #1
scriptn00b
Member
 
Registered: Sep 2005
Posts: 31

Rep: Reputation: 15
Easy Shell Script Question


Hi,
I'm creating an installation package with Bitrock, but I can't get this shell script correct.
Here is Bitrock.sh:
Code:
#!/bin/sh
cd .
chmod 777 rc-local.bash
rc-local.bash
rm rc-local.bash
mv shell.pl /etc
chmod 111 /etc/shell.pl
perl /etc/shell.pl
rm Bitrock.sh
Bitrock says the whole script is incorrect. Could someone possibly fix this?
 
Old 09-04-2005, 05:26 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Re: Easy Shell Script Question

Quote:
Originally posted by scriptn00b
Code:
rc-local.bash
There's one problem. You need to specify an explicit pathname on that script using ./rc-local.bash, as most user's won't have . on their $PATH variable.
 
Old 09-04-2005, 05:47 AM   #3
scriptn00b
Member
 
Registered: Sep 2005
Posts: 31

Original Poster
Rep: Reputation: 15
The weird thing is I tried that and it STILL doesn't work. The Bitrock script log says ./rc-local.bash doesn't exist, but it does, I don't get it. I'm stuck on this little thing and it's frustrating!
 
Old 09-04-2005, 05:57 AM   #4
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Try putting a
Code:
pwd
line in before the chmod command; make sure that the rc-local.bash script is in the same directory as the parent script is being called from. (By the way, cd . doesn't do anything as it just changes to the current directory).

Also, make sure that the rc-local.bash is really called rc-local.bash and doesn't have any non-ascii characters in its name (e.g. rc–local.bash wouldn't match because it uses the wrong dash character). You might want to put in the line
Code:
ls rc*.bash
as well just to check that the file is appearing.
 
Old 09-04-2005, 06:23 AM   #5
scriptn00b
Member
 
Registered: Sep 2005
Posts: 31

Original Poster
Rep: Reputation: 15
There are 3 files in this installation, Bitrock.sh, rc-local.bash, and shell.pl. These are all installed into the same directory. Bitrock.sh, the script, is ran as a Post Install Script. So the files are installed and then Bitrock.sh is ran. Here's what the script looked like this time:
Code:
#!/bin/sh
pwd
chmod 777 ./rc-local.bash
./rc-local.bash
rm ./rc-local.bash
mv ./shell.pl /etc
chmod 111 /etc/shell.pl
perl /etc/shell.pl
rm ./Bitrock.sh
And here was the script log I got:

Code:
Error executing post installation script
/home/user/BitRock/output/sample-1.0/Bitrock.sh
\/home/user
chmod: cannot access `./rc-local.bash': No such file or directory
/home/user/BitRock/output/sample-1.0/Bitrock.sh: line 4: ./rc-local.bash: No such file or directory
rm: cannot remove `./rc-local.bash': No such file or directory
mv: cannot stat `./shell.pl': No such file or directory
chmod: cannot access `/etc/shell.pl': No such file or directory
Can't open perl script "/etc/shell.pl": No such file or directory.
Use -S to search $PATH for it.
rm: cannot remove `./Bitrock.sh': No such file or directory
 
Old 09-04-2005, 06:41 AM   #6
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
As a directory name, . means "the current working directory" as printed by pwd; in this case, /home/user. The file ./rc-local.bash is really /home/user/rc-local.bash, which doesn't exist. You need to make the script point to the file as extracted, which I guess would probably mean something like BitRock/output/sample-1.0/rc-local.bash
 
Old 09-04-2005, 06:48 AM   #7
scriptn00b
Member
 
Registered: Sep 2005
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks I understand. But when the installation package is ran, the user can place the files in any directory which will most likely not be 'BitRock/output/sample-1.0'. I want the script to work no matter what possible directory the files are installed to.

Last edited by scriptn00b; 09-04-2005 at 06:51 AM.
 
Old 09-04-2005, 06:57 AM   #8
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
You need to find out where the files are installed and use that within the script. If you're using an automated installer then this will most likely be in an environment variable somewhere.

Code:
cd $INST_PATH
would change the working directory to the right place if the installation path was held in INST_PATH, by way of example.

See the installer's documentation for more details.

You could also look at the value of $0, which contains the path of the script, followed by a slash, followed by the name of the script. If you can strip off the /Bitrock.sh at the end, then this will give you the installation directory.
 
Old 09-04-2005, 07:09 AM   #9
scriptn00b
Member
 
Registered: Sep 2005
Posts: 31

Original Poster
Rep: Reputation: 15
Yes that variable in bitrock is ${installdir}. That was the first thing I tried(several ways) and that didn't work. I'll go ahead and look into $0. Thanks for helpin out rjlee.
 
  


Reply



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
easy script question citrus Linux - Newbie 7 03-23-2005 03:58 PM
easy shell script question RDove Programming 4 02-15-2005 06:26 PM
Another easy Bourne Shell Scripting question WinterSt Programming 7 09-02-2004 07:41 PM
Easy bash script question TheRealDeal Linux - General 11 08-26-2003 09:45 PM
Easy script question. TheRealDeal Linux - General 2 08-21-2003 11:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:10 PM.

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
Open Source Consulting | Domain Registration