LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 04-06-2005, 03:39 AM   #1
davatar
Member
 
Registered: Dec 2004
Location: Washington State
Distribution: Slackware
Posts: 46

Rep: Reputation: 15
bash commands


I have a question reguarding executing files. Is it possible to execute a script from a different directory, making the script believe you are executing it from the directory it lives in?

For example, this is my situation:

I have Cube 3D on my box, but it is not a package or source to compile, it simply runs "as is" once extracted into a directory. The scripts obviously are written to use whatever path you're located at when you execute the main script. This gives me path errors when executing from a different directory, because the script is trying to find the necessary files in /whatever/directory/I'm/in/bin_unix/blah/blah instead of
/opt/cube/bin_unix, where it's all actually located.

Instead of editing all the scripts included with the game.. is there a way to make it appear as if the script was executed from it's root directory? (All of this, so that I may place a symlink to it in /usr/bin?)

~Davatar
 
Old 04-06-2005, 03:54 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
Yes, there's a way!
Code:
# cat >/usr/local/bin/myCube.sh <<-"THEEND"
#!/bin/bash
cd /opt/cube && ./cube
THEEND
# chmod 755 /usr/local/bin/myCube.sh
Now just use /usr/local/bin/myCube.sh, which should be in your PATH. HTH.

Yves.

Last edited by theYinYeti; 04-06-2005 at 03:55 AM.
 
Old 04-06-2005, 04:05 AM   #3
davatar
Member
 
Registered: Dec 2004
Location: Washington State
Distribution: Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Awesome! Thanks. =)
 
  


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 commands Obie Linux - Security 4 08-15-2004 03:42 PM
Help with BASH Commands rridler Linux - Newbie 3 04-16-2004 05:43 PM
Bash commands PhuckFonix Linux - Newbie 2 03-30-2004 08:13 PM
ksh commands in bash nkelle Linux - General 2 11-13-2003 12:11 PM
Bash commands wprescott Linux - Distributions 6 04-27-2002 03:56 PM


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