Alex Antonov
Alex Antonov

Reputation: 15146

Ruby script from the bash

Let suppose I wrote the ruby script and I want to run it by my user at every path, just like a usual command.

What I need to do to implement this option?

IE I run this command like this:

ruby mp3split -argument1 s

Now I need to have this command everywhere as one user:

mp3split -argument s

Upvotes: 0

Views: 69

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 120990

Put the hashbang line at a very top of your ruby file:

#!/usr/bin/env ruby

and make your ruby script executable:

chmod +x mp3split

Now you might try to run it with

/path/to/your/script/mp3split ...

To be able to run it w/out the necessity to specify the full path:

export PATH=$PATH:/path/to/your/script

Put the line above somewhere in the .bashrc or .profile to make it persistent between sessions.

NB Besides the above, you might find this SO question interesting.

Upvotes: 2

Related Questions