LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 03-13-2009, 02:12 AM   #1
ahendo10
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Rep: Reputation: 0
Alias Problem


Hi there,

I'm a newbie with a specific goal: to get my todo.txt to display on my os x desktop. Now that I've figured this out using Geektool, I'd like to create an alias to edit my todo.txt quickly. I've been trying to edit .bash_profile to create this alias, but something is going wrong.

I'm using this page as my guide. They suggest these edits to the .bash_profile:

# Access todo.sh from anywhere in the file tree. Add the following to your ~/.bashrc file (~/.bash_profile for Mac and Cygiwn users):

PATH=$PATH:"/path/to/your/todo/scripts"

# Avoid typing todo.sh every time. Add the following to your ~/.bashrc file (~/.bash_profile for Mac and Cygwin users):

alias t='todo.sh -d /path/to/your/todo.cfg'


Then you simply type t add laundry from anywhere in your file tree to add a task.

So, coming from that, here's how my .bash_profile reads:

PATH=$PATH:"/users/Andy/todo.sh"
alias t='todo.sh -d /users/andy/todo.cfg'

But when I try to add to the todo list i get this:

andy-hendersons-macbook:~ Andy$ t add "don't forget the milk"
-bash: todo.sh: command not found

In place of the first line in the .bash_profile, I have also tried:

PATH=$PATH:"/users/Andy/documents/todo.txt"

and

PATH=$PATH:"/users/Andy/documents/todo/

The Todo.sh is in my ~/Andy/ folder, but the .txt file it refers to is in my ~/andy/documents folder. However, now that it's being edited by Geektool I guess it looks in finder like a folder that contains several different .txt files, which is why I tried the version ending in /todo/.

Do you have any thoughts? Could I give any more information about what I'm doing? Thanks a lot.

-Andy
 
Old 03-13-2009, 02:30 AM   #2
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
Hi, and Welcome to LQ!

Quote:
Originally Posted by ahendo10 View Post
Hi there,

...
So, coming from that, here's how my .bash_profile reads:

PATH=$PATH:"/users/Andy/todo.sh"
alias t='todo.sh -d /users/andy/todo.cfg'

...

-Andy
First I don't use Mac and I don't intend to, so I might be off about Macs. However you configuration is having a case problem. You path is pointing a /users/Andy/ location, while your alias is pointing a /users/andy/ location (notice the different cases of A and a). So if your OS X configuration is using a case sensitive file system, (which looks like the case BTW) you are creating an incorrect alias.

So it looks like a simple case of changing the "andy" in the alias to "Andy". Good luck.

EDIT: Sorry, I didn't read carefully the first time. Try logging out and logging in to make your changes to the .bash_profile. If you have the correct paths set it should work. If you want to check immediately without logging out and in, try
$ source ~/.bash_profile
before you execute t.

Check the case difference too. If your filesystem is case sensitive file and directory names has to be corrected accordingly (Eg: andy/Andy, todo.sh/Todo.sh). And also make sure the todo.sh file is executable (Eg: $ chmod u+x ~/todo.sh)

Last edited by SkyEye; 03-13-2009 at 02:45 AM. Reason: I didn't read the post correctly the first time
 
Old 03-13-2009, 02:43 AM   #3
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 974

Rep: Reputation: 56
Maybe try

alias t='./todo.sh -d /path/to/your/todo.cfg'

also make sure that you chmod +x todo.sh so it can be executable.
 
Old 03-13-2009, 03:54 AM   #4
ahendo10
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Okay, I had already made the todo.sh an executable file I think. For instance, I am able to do things like this:

andy-hendersons-macbook:~ Andy$ sh /users/andy/todo.sh add "Don't forget the milk"
TODO: 'Don't forget the milk' added on line 2.

But the alias thing is still not working. I tried both accounting for case and also the suggestion in the second post.

On another blog post, this guy suggests a different way of making an alias. Would anyone mind writing briefly how I could make this work given my current set up? Here's the line in particular:

6) Take todo.sh and move it to /usr/local/bin so you can call it from any directory:

sudo mv todo.sh /usr/local/bin/.


Thanks!
 
Old 03-13-2009, 04:30 AM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,040

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
First thing,

Quote:
Originally Posted by ahendo10 View Post
# Access todo.sh from anywhere in the file tree. Add the following to your ~/.bashrc file (~/.bash_profile for Mac and Cygiwn users):
Seems to imply that you have to use ~/.bashrc for pc, and ~/.bash_profile for mac/cygwin. If that's what they mean, then it's false. The bash init files are not arch dependent. ~/.bashrc is for non-login interactive shells (i.e. when you launch an xterm), while ~/.bash_profile is for interactive AND login shells (i.e. when you login in text mode without kdm or the like, or when you pass --login explicitly).

Read the "INVOCATION" section in the bash man page if you want to know more about the bash init files. And use the correct one depending on how do you open your bash session, or both if you want to be sure.

You should double check the value of $PATH (echo $PATH) on your shell. If the path hasn't been added then you are using the wrong file, or there's something wrong in the code you are editing. You can also use "which" to check if a given command is in the path, and you can use "alias" without arguments to see the aliases that have been defined. Some things to check.

Last edited by i92guboj; 03-13-2009 at 04:31 AM.
 
Old 03-13-2009, 09:53 AM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 237

Rep: Reputation: 44
Quote:
Originally Posted by ahendo10 View Post
PATH=$PATH:"/users/Andy/todo.sh"
I think the above is your problem. Bash is looking in a directory named todo.sh for your executable. The path should be:
Code:
PATH=$PATH:"/users/Andy/
 
Old 03-13-2009, 11:08 AM   #7
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,040

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Quote:
Originally Posted by norobro View Post
I think the above is your problem. Bash is looking in a directory named todo.sh for your executable. The path should be:
Code:
PATH=$PATH:"/users/Andy/
That's it, it's curious how it is always the simplest thing which goes unnoticed.
 
Old 03-13-2009, 01:32 PM   #8
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 237

Rep: Reputation: 44
i92guboj, simple I can do
 
Old 03-13-2009, 05:14 PM   #9
ahendo10
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Original Poster
Rep: Reputation: 0
I've got a new error!

Okay, so we must be getting somewhere because my error is different now! Thanks guys.

Here is the text of my .bash_profile:

PATH=$PATH:"/users/Andy/"
alias t='todo.sh -d /users/Andy/'
~
...
~
~
".bash_profile" 2L, 60C

And this is what I'm now getting when I try to use the alias:

andy-hendersons-macbook:~ Andy$ t add "don't forget to thank LQ for their help"
./todo.sh: line 320: .: /users/Andy: is a directory
Fatal Error: is not a directory
andy-hendersons-macbook:~ Andy$

Again, if I run things like this, it works:

andy-hendersons-macbook:~ Andy$ sh /users/andy/todo.sh add "don't forget to thank LQ for being l33t"
TODO: 'don't forget to thank LQ for being l33t' added on line 3.
andy-hendersons-macbook:~ Andy$

Any thoughts? Thanks again.
 
Old 03-13-2009, 05:17 PM   #10
ahendo10
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Also, this gives me the same error:

PATH=$PATH:"/users/Andy/"
alias t='todo.sh -d /users/Andy/todo.cfg'

andy-hendersons-macbook:~ Andy$ t add run!
/users/Andy/todo.sh: line 320: .: /users/Andy/: is a directory
Fatal Error: is not a directory
andy-hendersons-macbook:~ Andy$
 
Old 03-13-2009, 05:41 PM   #11
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 237

Rep: Reputation: 44
If post #10 is a change to your .bash_profile did you source it?
Code:
source .bash_profile

Last edited by norobro; 03-13-2009 at 05:43 PM. Reason: changed .bashrc to .bash_profile
 
Old 03-13-2009, 06:18 PM   #12
ahendo10
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by norobro View Post
If post #10 is a change to your .bash_profile did you source it?
Code:
source .bash_profile

Yes this is it. It works perfectly now. What does sourcing something do? Thanks a lot for the help.

Best,
Andy
 
Old 03-13-2009, 07:10 PM   #13
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 237

Rep: Reputation: 44
You're welcome. I'm glad that you got it working!

.bash_profile & .bashrc are read when you log in or when you open a new shell. When you made the changes to your .bash_profile they had no effect on your current shell. So by typing "source .bash_profile" you made the current shell reread it. Logging out and then logging back in would have had the same effect.

From "man bash":
Quote:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.
Norm
 
  


Reply

Tags
bash, profile


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
Ip Alias problem DarkSun4241 Linux - Networking 1 07-11-2006 05:29 PM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 12:40 AM
alias problem p41elvis Linux - Newbie 1 04-28-2005 10:28 AM
Eth0 IP Alias Problem assyrian47 Slackware 1 04-20-2005 11:50 AM
alias problem petarsabev Slackware 1 10-12-2003 02:40 PM


All times are GMT -5. The time now is 05:24 PM.

Main Menu
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