I'm trying to run a executable file using applescript in FileMaker.
I've been trying...
do shell script "./firstscript"
This results in the error "sh: ./firstscript: No such file or directory"
If I type './firstscript' directly in bash the file is properly being executed.
Any ideas on how I should be pointing to my executable file inside the apple script?
You probably have the wrong working directory - use a full path instead, e.g.
do shell script "/path/to/firstscript"
Related
I have project structure like this
project
|app
|script
inside script folder, there are files such as 'run'
run file content:
#!/bin/bash
npm start
I want to run the file 'run' while I'm at the root of my project by typing only command 'run'. How would you do this?
This is sh file. In order to execute sh file on linux this file has to be executable.
Make sure this file has X permission.
If there is no x permission on file simply execute the command
chmod +x run.sh
Then execute the file by typing
./run.sh
For windows you need to create .bat file.
I'm not quite sure what you want but assuming you need a way to execute a file from node.js, you can use child_process module and child_process.exec method to start any executable.
Assuming the run file in the script directory is executable (if not, run chmod +x script/run), it can be executed by running ./script/run.
If you want to avoid having to type the name of the directory (script), you could append the script directory to your PATH environment variable. If you’re running a POSIX compatible shell (not csh or tcsh), this can be done using:
export PATH="$PATH:/path/to/project/script"
This will allow you to run any executable command in the script directory without having to specify the name of the directory, e.g., run.
NB: be sure that there aren’t common command names in the script directory as these commands can be run from any directory (including outside the project directory) after it has been added to the PATH. That’s also why I suggest adding it to the end of the PATH (so it’s the last directory that’s searched for executable commands).
I wrote a shell script where I copy my .bashrc file as well as custom dotfiles to a backup folder and then replace them in my home folder with another .bashrc file which will then source my custom dotfiles.
However, after the script does its job, if I try to execute the aliases I included in the new files I get the error No command found. Only after I source the .bashrc file manually in the terminal I have access to them.
From what I understand, the script I'm running is executing in a sub-shell (?) which will terminate on execution.
How can I run the script and have new commands/aliases/functions available without having to source the .bashrc file myself or restarting the terminal?
Well, it appears that instead of running my script via sh script.sh, I can source it like source script.sh, which will behave exactly as I wanted.
Solution
Right now, I have shellScript.sh and test_me.py in a folder ABC/def. shellScript.sh calls test_me.py. I'm trying to call shellScript.sh from the ABC folder. So far, I keep on getting "No such file or directory" errors.
I've tried calling the python script from the shell script such as:
python /ABC/def/test_me.py
but this still gives me the same error.
How do I fix this?
Make sure your home directory starts by a capitalize H, if it does not (which is highly probable) your script won't work.
If the problem is not in the path or filename, then it could be in the way you are executing the shellScript.sh:
./shellScript.sh
might fix it provided you have the proper execute bit set on the script file. If not, try this:
sh /proper/path/to/shellScript.sh
If that does not fix it, then try to cd to the directory in the script before the python line:
cd /to/proper/folder
python test_me.py
I am very new to bash and using .sh files. I am trying to run the program aescrypt by calling it in a .sh file as follows (aescrypt is in the same directory as the .sh file) :
./aescrypt -e -p password file.txt
It throws the following error:
./aescrypt no such file or directory
Am I doing it wrong?
ps- I realy don't want to add it to the PATH variable as I will be using this on more than one computer that resets every day.
The location of the script is irrelevant. The thing that matters is the working directory of the process executing the script. The simplest solution really is to add aescrypt to a standard location like /bin or /usr/bin. If neither of those is acceptable, perhaps /usr/local/bin is an option. Otherwise, just use the full path of aescrypt in your script. Either hard code it, or if it is in the same directory as the script, try:
$(dirname $0)/aescrypt ...
(Note that hardcoding is more reliable, but less flexible. If you move the executable, the script will break. But using dirname will break if the script changes directory during execution.)
how about if you call the program like ./aescrypt.sh, thats the way to call an .sh programm througt the terminal
First off all, you have also to change the permissions of the file to make it executable, the way to make that is to write in the terminal, the command:
sudo chmod 765 aescrypt.sh
For that you have to be located where the file is
I am new to C, so apologies if this is a naive question. I have been given a script to execute C programs. The first line has the format:
./directory_name program_name program_parameter_1 program_parameter_2
When I execute the script from a different directory I get the following error:
No such file or directory.
When I execute the script from the named directory, I get a different type of error:
directory_name is a directory.
Does someone know what the script file is trying to accomplish?
I have read about commands that change directories through script files, but they don't seem to have this format (i.e. directory name following ./), so I am confused.
Thanks!
If the script is presenting a different behavior depending on the directory you are running it, that means the code inside the file is referencing some dependency that is mapped from a specific location.
Why don't you check the source and learn more about what the script is doing?
Are you confused about "./"? That's how you execute a script, you don't have to worry about what kind of interpreter will process this code, that's defined in the shebang (#!).
You can read more about it here:
http://en.wikibooks.org/wiki/C_Shell_Scripting/Hello