AppleScript does not find a command line tool located in /usr/local/bin/.
I've got the following AppleScript command:
do shell script "/usr/local/bin/bitbar refresh"
It results in the error:
error "env: node: No such file or directory" number 127
I checked the directory and the command line tool is indeed in that location. AppleScript does find other tolls installed there, such as brew.
Any ideas?
Try initially adding a new path (i.e. /usr/local/bin/) to the shells PATH variable before running the bitbar refresh command.
For instance, change your do shell script as follows:
do shell script "PATH=/usr/local/bin:$PATH; bitbar refresh"
Related
Problem summary
I'm trying to launch a .sh script via Windows 10 Cygwin (i.e. mintty.exe > bash.exe) but neither .profile, .bash_profile, or .bashrc are loading, which I need to update PATH env variable with Cygwin's bin directory.
Background
I'm trying to launch a script finder.sh:
#!/bin/bash
find .
read
from C:\Users\Bo\Temp\. It has unix line endings and executable bit set.
I have Cygwin installed at C:\Users\Bo\AppData\Local\Programs\cygwin64\. I do not have this path in either System or User Windows' Environment Variables (and I don't want to!). My runcoms all live in this directory under /home/Bo. My .bash_profile (and ATM .bashrc) have an export PATH="/cygdrive/c/Users/Bo/AppData/Local/Programs/cygwin64/bin":${PATH} in them.
I want to launch the script from Windows Explorer. I tried using the bash.exe and mintty.exe in the cygwin64\bin\ folder via Open > Choose another app > More apps > Look for another app on this PC. In either case the mintty window displays:
FIND: Parameter format not correct
meaning the Windows' find command was used not Cygwin's. So I have my script echo $PATH and the Cygwin/bin directory is not in PATH. If I add the proper export PATH statement from above to my own script it works fine. So, now to debug the launcher and runcoms...
I've put echo ${0} statements in .profile, .bash_profile, and .bashrc, none of which trigger which I run the .sh script, they are never run. I've read SO and the mans. I've tried creating a Shortcut to both mintty.exe and bash.exe passing a variety of -l -i -e - commands to each using Properties > Shortcut > Target and they are never run. E.g. running simply [..]\mintty.exe -h always doesn't even leave the window open.
How do I get my script to run in Windows Explorer via Cygwin's mintty.exe/bash.exe, and to read from a runcom to update PATH (to find Cygwin Linux commands, vs. updating Windows Environment Variable)?
Two part fix:
A) set a Windows Environment Variable for BASH_ENV to a .bash_env under your Cygwin HOME, and export the PATH variable to include the Cygwin/bin directory from that file. I cannot find a decent reference for this in Cygwin documentation because it seems to be simply a bash thing, but this variable is what bash looks for when running non login/interactively. Best reference: Cygwin shell doesn't execute .bashrc.
And B) run the .sh with bash.exe from Cygwin/bin using Open With....
ALSO, annoying Windows bug: when you select a program to Open With... your .sh script, it will always run 1x with a CWD from your C:\Windows\System32 directory(?!) and all other times will run fine with the CWD as the directory from your .sh script.
gitk is not working for me. I get the error saying "the term 'gitk' is not recognized as the name of a cmdlet, function, script file, ...."
One interesting thing I noted was that inside C:\Program Files(x86)\Git\bin\, there was a gitk file, but it had no extension. Most other files in that folder had a .exe extension.
I also made sure that C:\Program Files(x86)\Git\bin\ is specified in the PATH environment variable.
Also, I tried adding C:\Program Files(x86)\Git\cmd\ to PATH because it contains a gitk.cmd file, but that did not help either.
Edit : I was using Powershell earlier, since I have poshgit installed. I switched over to bash, and I was able to do gitk --all from there.
I just got it to work after having the same problem.
At the PowerShell prompt it typed: "Bash" and hit return.
This put me into a bash shell.
Then I typed "gitk" at the Bash prompt and it worked.
So that gitk file is a UNIX shell script and requires the shell to work.
I suppose you could always have one of your Power Shell window in Bash mode and then this tool is available.
I'm making a series of bash scripts to remove to nuisance from manually typing out navigation commands into my cygwin terminal. He's one that navigates to my xampp /www/ directory:
#!/bin/bash
cd /cygdrive/c/xampp/htdocs/www
When I run it with the following command:
$ ./www.bat
I get the following error:
C:\Users\user>cd /cygdrive/c/xampp/htdocs/www
The system cannot find the path specified.
What's strange is that when I type that command out manually it navigates to the intended directory without issue. My first thought is that it's an issue with Cygwin's disk drive naming, but if that was an issue it would fail upon manual typing.
What gives?
The error you're getting is from the windows command line interpreter. It gets called because your script has the .bat extension. It should be called www.sh instead.
However, you can't do what you want with a script: a new process would be spawned to run your script, the new process would cd to your directory but at the end of the script the process would end and you'd be returned to the calling shell's process which would have the old current directory. You would need to source the script from bash (. /path/to/www.sh) so that it would run in the same process as the calling shell, but that would be overkill for what you want. Just add this to your .bashrc in your home directory (/home/<user>/.bashrc):
alias www='cd /cygdrive/c/xampp/htdocs/www'
To make shortcut for command line function to make it available everywhere in my mac i usually add this line in ~/.bash_profile
To include one terminal execution file, i usually use: alias yiic='~/Script/Yii/1.1.13/yiic'
yiic is terminal execution file.
And then now i have example this from another site: export PATH=${PATH}:/development/sdk/android-sdk-macosx/tools
I understand this command like import all execution file in tools directory, but what is the meaning of ${PATH}: ?
${PATH} is the other folders that your computer will look in. It's automatically set up by your OS. If you do the following command in your Terminal, you'll see all the folders your computer looks in:
echo $PATH
#!/bin/bash
echo "Testing"
cd "/cygdrive/x/Internal Communications/Riccardo/"
filename=htdocs-`date +%A`.tar.gz
tar cvzf $filename "/cygdrive/c/Program Files/Zend/Apache2/htdocs"
The above script is working when it is called inside cygwin console, but when I try to call it from a batch file I get "command not found" for date and tar command. I think that bash.exe does not have the PATH set up.
I need to run that script from that batch file because I want to add the script to the task scheduler.
As has already been said, you need to add the Cygwin binaries to your path. To do so, right click on "My Computer", click "Properties", then "Advanced", then "Environment Variables".
Create a new environment variable with name "CYGWIN_HOME" and value "C:\cygwin" (or wherever you installed cygwin. The default location is "C:\cygwin\" so this should probably work for you).
Then edit the environment variable named "PATH", and tack on the following to the end:
;%CYGWIN_HOME%\bin;%CYGWIN_HOME%\sbin;%CYGWIN_HOME%\usr\bin;%CYGWIN_HOME%\usr\sbin;%CYGWIN_HOME%\usr\local\bin;%CYGWIN_HOME%\usr\local\sbin
Close your command prompt, then reopen it. The cygwin binaries should now be available. You can double-check this by typing "which bash". It should report the location of your bash executable.
FWIW, Cygwin has cron.
Are you calling your script like this?
bash --login -i ./myscript.sh
Put your cygwin bin directory (likely C:\cygwin\bin) on your PATH environment variable.
This would also give you the benefit of being able to use commands like tar, ls, rm, etc. from a regular console windows and not just a Cygwin console.
If this script is invoked from a Windows command shell, the first line will result in an error since #!/bin/bash is not a recognized Windows command and # is not a valid comment delimiter in a batch file.
So, the bottom line is that this script runs as a regular batch file rather than from within Cygwin's bash. As noted by matt b, you likely do not have the Cygwin executable path in your PATH environment variable. Without this, the batch file cannot find the Cygwin utilities (tar and date).
I just had this problem.
Editing the environment variable works great. But if you are have no admin rights you canĀ“t do that.
In this case you can execute your commands by using the absolute path like:
/usr/bin/tar cvzf $filename
/usr/bin/cat $filename
If you do so your bash script works even if you call it from a batch file.