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. |
|
 |
09-04-2005, 03:56 AM
|
#1
|
|
Member
Registered: Sep 2005
Posts: 31
Rep:
|
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?
|
|
|
|
09-04-2005, 05:26 AM
|
#2
|
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990
Rep:
|
Re: Easy Shell Script Question
Quote:
Originally posted by scriptn00b
|
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.
|
|
|
|
09-04-2005, 05:47 AM
|
#3
|
|
Member
Registered: Sep 2005
Posts: 31
Original Poster
Rep:
|
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!
|
|
|
|
09-04-2005, 05:57 AM
|
#4
|
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990
Rep:
|
Try putting a 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 as well just to check that the file is appearing.
|
|
|
|
09-04-2005, 06:23 AM
|
#5
|
|
Member
Registered: Sep 2005
Posts: 31
Original Poster
Rep:
|
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
|
|
|
|
09-04-2005, 06:41 AM
|
#6
|
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990
Rep:
|
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
|
|
|
|
09-04-2005, 06:48 AM
|
#7
|
|
Member
Registered: Sep 2005
Posts: 31
Original Poster
Rep:
|
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.
|
|
|
|
09-04-2005, 06:57 AM
|
#8
|
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990
Rep:
|
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.
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.
|
|
|
|
09-04-2005, 07:09 AM
|
#9
|
|
Member
Registered: Sep 2005
Posts: 31
Original Poster
Rep:
|
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.
|
|
|
|
| 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:11 PM.
|
|
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
|
|