LinuxQuestions.org
Review your favorite Linux distribution.
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-06-2009, 04:48 AM   #1
sloteel
Member
 
Registered: Jul 2005
Distribution: Ubuntu 18.04
Posts: 71

Rep: Reputation: 15
Problem with a bash script


Hi, I made this script to workaround some 3d issues I have:

Quote:
#!/bin/bash
if [ -f lockfiles/cycle-docky ]; then
gconftool-2 --set /apps/metacity/general/compositing_manager --type bool true
gnome-do &
rm lockfiles/cycle-docky
else
gconftool-2 --set /apps/metacity/general/compositing_manager --type bool false
killall gnome-do
touch lockfiles/cycle-docky
fi
This script works flawlessly is launched from a terminal, but if I launch it with a shortcut the touch doesn't create the file. What could the problem be?
 
Old 02-06-2009, 04:56 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Not sure, but I would start with putting absolute paths everywhere.

/usr/bin/touch /home/jlinkels/lockfile/.....
etc.

jlinkels
 
Old 02-06-2009, 11:56 AM   #3
sloteel
Member
 
Registered: Jul 2005
Distribution: Ubuntu 18.04
Posts: 71

Original Poster
Rep: Reputation: 15
Thanks, it works!
 
Old 02-07-2009, 06:01 AM   #4
shyamkumar1986
LQ Newbie
 
Registered: Feb 2009
Posts: 19

Rep: Reputation: 1
Path issues ... A Total nightmare that one!!!

Last edited by shyamkumar1986; 02-09-2009 at 08:38 AM.
 
Old 02-09-2009, 02:12 PM   #5
tmcguinness
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Rep: Reputation: 0
Always use absolute path in scripts!

The reason for this is that your shell that you opened actually runs .bash_profile or .profile or some iteration of a user file which sets your paths for you.

Long story short - the path must be explicitly set in the beginning of the script or you must explicitly use absolute paths for each file use in the script.

Last edited by tmcguinness; 02-09-2009 at 02:14 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
bash script problem noir911 Programming 2 04-07-2006 10:11 AM
bash script problem GATTACA Programming 3 06-13-2005 09:59 AM
Problem with this bash script cantabile Programming 3 06-06-2005 05:31 PM
bash script problem cookie_ie Programming 3 03-23-2005 02:19 PM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM

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

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