Monday, April 25, 2011

Executing own Unix command in terminal?

I made an Unix command, macmac2unix, which converts Mac's Word file for Unix platforms.

I would like to run the command as

$macmac2unix file1 file2 file3 ...

Problem: How can I run this command in every path?

I added the following to .bashrc unsuccessfully

CDPATH=:/Users/Sam/Documents/Unix
From stackoverflow
  • Add it to PATH, not CDPATH.

  • Try adding

    export PATH=$PATH:/Users/Sam/Documents/Unix
    

    to your .bashrc

    Make your script executeable be sure it's located in /Users/Sam/Documents/Unix. You could reread your .bashrc with:

    ~> . ~/.bashrc
    

    But if you already played around with your enviroment variables a restart of your terminal would be cleaner.

    Masi : No change. You can find my .bashrc here: http://dpaste.com/8008/
    Node : Hm, remove the line 5 and restart your terminal. Or try executing 'export PATH=$PATH:/Users/Sam/Documents/Unix' directly in your terminal for testing purposes.
    Masi : It seems to work. I get the following error: -bash: /Users/Sam/Documents/Unix/macmac2unix: Permission denied
    Masi : I get the program work by running:$ chmod +x macmac2unix . Thank you!
  • Try adding it in PATH like this:

    PATH=/Users/Sam/Documents/Unix:$PATH
    

0 comments:

Post a Comment