LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-05-2010, 10:36 AM   #1
sir-lancealot
Member
 
Registered: Aug 2007
Posts: 346

Rep: Reputation: 31
change running path in bash


We have a custom app that runs on boot on some older hardware running DSL linux, and their startup manager was quite simple. We purchased some newer Asus eeebox's which run xandros and things are quite stable and run nice with 1 exception.

The application only runs from the root (/) location. This box auto logs in as 'user' and there is a /home/user/.kde/Autostart folder where you can stick scripts to run at boot. So I have a start.sh script, and with little bash programming tried things such as;

sudo cd /
sudo /startapp.pl

but the errors start spewing with the basic;
can't find data/xyz as it's looking in the local. I thought there was a basic cwd (change working directory) but everything I try just forces the run from that location.

Any ideas or suggestions are appreciated, but things like can you change the code, etc. can't be done, so it must be a programming thing. The only other thought I had but not sure, can you do a cronjob with @boot or something, that when the box starts, it can run this job as root and fire off?

Thanks
 
Old 02-05-2010, 10:47 AM   #2
mjones490
Member
 
Registered: Sep 2005
Distribution: LFS
Posts: 60

Rep: Reputation: 22
What would happen if you created a symlink in the local directory back to where the real data directory is?
Code:
ln -sv /home/user/data /data
 
Old 02-05-2010, 12:41 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Or, it could be that some security feature (selinux?) has restricted applications from running with $PWD == / Have you tried launching the application from /etc/rc.local or making it into a system daemon, rather than waiting for KDE to start (problematic if the application requires X, or has any interactive element to it)?
--- rod.
 
Old 02-05-2010, 05:42 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Why don't you chdir from the program itself if it has to run from /? You can at least print an error if it fails. Also, cd is a built-in: using sudo, if it works, will run whatever cd program happens to be there as a separate process, but the shell will stay in the same place. You might do exec bash -c 'cd /; /path/to/app;' in a script, also. If that doesn't work, you might need to . bashrc or use -login.
Kevin Barry

Last edited by ta0kira; 02-05-2010 at 05:44 PM.
 
  


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
PATH set incorrectly and lost bash: vi command... how can I change .bashrc? Lindz Linux - Newbie 10 09-23-2009 05:01 AM
change windows path to unix path gibsosmart Linux - Newbie 7 09-15-2009 03:35 AM
PATH for Bash Gecopa Linux - General 7 06-23-2009 11:21 AM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 05:48 PM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 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
Open Source Consulting | Domain Registration