I am starting with spring-roo, so I downloaded it and now I'm trying to export the variable.
To get it, I tried:
PATH=$PATH:/Users/myUsr/spring-roo/bin
export PATH
PATH variable
my-Name-3:~ myUsr$ echo $PATH
/sw/bin:/sw/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin:/Users/myUsr/spring-roo/bin
In this path (/Users/myUsr/spring-roo/bin), there is roo.sh
But then, I can not run the command roo as it is supposed to be.
You are not supposed to be able to run a command roo (no .sh), when all you have is roo.sh. Run roo.sh instead. There is no magic dropping of extensions in Unix.
Are you in the directory where the root.sh is ? Just give a try by being in that directory to run the shell script. Also check the permissions of the file.
Related
I've been struggling with "PATH" issues while setting up Rails and other things on Mac for a long time now, and I can't get a straight answer about how I can just see my $PATH and change it. I'm just running the Terminal right now, but if I need to run another program to run Bash commands or something I can probably figure out how to do that.
Execute the following command in Terminal to view the current value of PATH:
echo $PATH
To modify this PATH variable, create a .bash_profile file in your home directory (/Users/username/.bash_profile) and add a line similar to this:
export PATH=$PATH:/new/directory/location
To see your current PATH,
echo $PATH
in a Terminal window.
type:
echo $PATH
You can check your .bash_profile file and edit $PATH variable there. If that file does not exists then you can create a new one and you can export PATH there using:
export PATH=/usr/local/bin:/usr/local/mysql/bin:$PATH
I'm trying to use a script in grunt and node to dump a database.
When I run It return me this error:
/bin/sh: mysqldump: command not found
I have already contacted the creator of the script and we have understand that the problem is the configuration of my localhost.
I'm using XAMPP 1.8.2-3 in OSX
How can I use correctly mysqldump
Thanks
Try:
export PATH=$PATH:/Applications/XAMPP/bin
Then run your script.
So you don't have to do this in the future, check your .profile file in your home directory. There should be a line that starts with export PATH, something like (only an example):
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Just add your XAMPP path to it:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/XAMPP/bin:$PATH
The different directories are separated by colons only, don't add any whitespace.
I installed Sencha SDK and Sencha command on my mac-mini and done with some sample app.. but suddenly after some time when I tried to run sencha command on terminal, I got the response as '-bash: sencha command not found', I don't know why this was happened. Earlier I didn't find such type of response but now I got this error. Please tell me what are the possible scenarios for this thing to be happened.. Thanks for your help
Alens-Mac-mini:touch-2.2.0 SenchaTools$ sencha
-bash: sencha: command not found
You should procede that way:
Verify if this command is contained in PATH. PATH is an environment variable holded by bash and initialized when a new user is logged in (.bash_profile file for all user and the corrispective into home for single user). So check what echo $PATH told you and verify if this command is contained into those folder
Probably, from step 1, the answer will be "No, it isn't". So you have to procede this way: use whereis command to search this command (that will be an executable script) and once you find it, you have two possibilities: one is to use it directly by specifying full path (returned from whereis command).
If you want to run simply it with sencha -arguments you have to add executable path returned by whereis ($PATH=$PATH:/returned/path/by/whereis) into file .bash_profile
In that way you should be able to execute your command from any "point" in your filesystem
The Sencha installer expects you to use bash as shell. It fails, if you use any other (like the nice zsh). You need to copy the content of .bash_profile to your shell startup-file (.zprofile in my case), save it and open a new terminal window.
Add PATH and VAR manually in .bash_profile file at the root of your user folder,
export SENCHA_CMD_3_0_0="/Users/you/Path/To/Sencha/Cmd/3.0.0.XXX"
export PATH=/Users/you/Path/To/Sencha/Cmd/3.0.0.188:$PATH
Find out more about this issue at sencha forum https://www.sencha.com/forum/showthread.php?245243-Command-not-found-mac-OSX-mountain-lion
I am on Mac's OS 10.6, and I am trying to learn a thing or two about shell scripting. I understand how to save a shell script and make it executable, but I am wondering what I can do or where I can save the file to make it global (that is, accessible no matter what folder I am in).
For example, if I save a .sh file in the /Users/username/ directory and make it executable, I can only execute that script in that specific directory. If I navigate to /Users/username/Downloads, for example, I can't execute the script.
Also, any suggestions of resources for learning more about shell scripting would be helpful. Thanks
/usr/local/bin would be the most appropriate location. Mac OS X has it in the PATH by default
There are two ways to do it -
Put your script in usr/local/bin and make sure it is executable(chmod +x my_script)(This is already set in the path, you can check by doing an echo $PATH)
Create a folder in your home directory called bin. (For your personal scripts)
cd ~ (Takes you to your home directory)
mkdir bin (create a bin folder)
vim .bash_profile (to set path environment variable)
export PATH=~/bin:$PATH (Press i then add this line and then do esc and type :wq)
Now you can just type the name of your script and run it from anywhere you want.
** NOTE: If you want to run the script with a shortened command rather than typing your entire filename, add the following to your .bash_profile:
alias myscript='my_script.sh'
Then you can run the script by simply typing myscript. (you can sub in whatever alias you'd like)
Traditionally, such scripts either go in ~/bin (ie: the bin directory in your home directory) or /usr/local/bin/ The former means the script will only work for you, the latter is for scripts you want anybody on the system to be able to run.
If you put it in ~/bin, you may need to add that to your PATH environment variable. /usr/local/bin should already be on the path.
In mac operating system
Open bash ~/.bashrc file.
add path of your script in your bashrc file , using
export PATH="$PATH:/Users/sher.mohammad/Office/practice/practiceShell"
Open your ~./bash_profile file and add [[ -s ~/.bashrc ]] && source ~/.bashrc
open new terminal window
Now whenever you will open your terminal your script will be loaded
This one is super easy if you are familiar with your bashrc file! This will entirely use just your .bashrc file and takes 2 seconds to accomplish.
(I use Arch Linux Manjaro so I use .bashrc located in my home directory)
The code to be placed in your .bashrc file:
# Simple bashrc method to launch anything in terminal from any directory
YOURCOMMAND () {
cd /path/to/directory/containing/your/script/ && ./YOURSCRIPT
}
As you can see, first you use the simple 'cd' command and give it the directory of the scripts location, then use '&&' so that you can make the next command executed right after, and finally open your script just as you would normally! Super easy and saved right in your .bash file! :)
Hope I've helped someone!
Sincerely,
AnonymousX
On using bash shell, write that script as function and then put it to the .bashrc or source the file which containing that function by "source file_name"
Now execute the script by function call in the shell.
Either saving it in /usr/bin (or any other directory present in PATH) or editing PATH to include the directory you saved it in will basically make it run in any directory.
from the working directory of 'script.sh'" mv [script.sh] /usr/local/bin"( not tested but seems to be the least complex way IMO.)
You should put it in the global executable directory on your machine. I think that would usually be /usr/bin on Unix-based operating systems (this would however most often require super user privileges on that machine).
You could also put it in any other directory that is in the $PATH environment variable, although it would only work for those users who have that directory in that variable.
You can find the value of $PATH by typing echo $PATH in a shell. The directories are separated by :.
I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)