This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Why am I getting “: No such file or directory” when trying to execute a bash script?
I have the following shell script..when running it the cd command keeps failing with below error..can anyone provide inputs what is wrong?
#\!/bin/sh
ANDROID_ROOT="/local/mnt/workspace/AU"
cd $ANDROID_ROOT
source build/envsetup.sh
lunch 12
: No such file or directoryal/mnt/workspace/AU
./test.sh: line 4: build/envsetup.sh: No such file or directory
<username:/local/mnt/workspace/username/scripts>
The line endings are goofed up. Run it through dos2unix.
Related
This question already has answers here:
Command not found error in Bash variable assignment
(5 answers)
Run bash commands from txt file
(4 answers)
Closed 5 years ago.
I have a script shell that is reading from a file. This is the command line text that i would like to run under the bin folder of neo4j
bin/neo4j-import --into /home/micmal/neo4j-community-3.0.1/data/databases/graph_test.db --id-type string --nodes:
I would like to use a script shell to get that command and go to the folder of neo4j and paste it so it runs.
my shell looks like :
#!/bin/bash
batch_import_value= `cat _batchfile.txt`
cd /home/neo4j-community-3.0.1/
echo $batch_import_value`
it doesn't seem work
Any idea?
This question already has answers here:
Why can't I change directories using "cd" in a script?
(33 answers)
Closed 5 years ago.
As a beginner of bash script, I wrote a simple script to change the directory. Here it is my source code:
#!/bin/bash
set -x
echo "---------------------START-----------"
cd /home/cocadas/Workspace/carnd/CarND-Behavioral-Cloning-P3
I save it as "start" in the /root folder. I change the property of the file to be executable, and then run it as below. The problem is that the execution command cd doesn't work. What did I miss?
cocadas#cocadas-ThinkPad-W540:~$ ./start
+ echo ---------------------START-----------
---------------------START-----------
+ cd /home/cocadas/Workspace/carnd/CarND-Behavioral-Cloning-P3 cocadas#cocadas-ThinkPad-W540:~$ cd
/home/cocadas/Workspace/carnd/CarND-Behavioral-Cloning-P3
cocadas#cocadas-ThinkPad-W540:~/Workspace/carnd/CarND-Behavioral-Cloning-P3$
Your ./start call creates a sub shell. Run source start or . start (. is an abbreviation of source) instead to execute your script directly in your command line, not in a nested container.
This question already has answers here:
Why do you need ./ (dot-slash) before executable or script name to run it in bash?
(9 answers)
Closed 5 years ago.
When I executeinit-hooks I get
bash: init-hooks: command-not found
here are the contents of init-hooks:
#!/bin/bash
set -e
printf '\ncopying hooks\n\n'
cp ./hooks/* ../../.git/hooks
When I execute cp ./hooks/* ../../.git/hooks from bash directly execution is successful.
(note this is the same command as what is in the script)
Proof of the files are in the directory and the results of execution:
Why does my script behave differently than the command/why is my script not found?
On the Linux systems (where bash comes from) the current directory is usually not included in the path for security reasons.
Run echo $PATH to check what directories are used to search for executables when they are provided in the command line without a path. The current directory (.) should not be there.
Run the script as ./init-hooks and bash will find it.
I suugest to run it following way
./init_hooks
or put fully qualified file name.
make sure to make the script executable
chmod +x ./init_hooks
This question already has an answer here:
Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
(1 answer)
Closed 7 years ago.
I am trying to run this simple bash script:
file_name=deploy
echo "Init File NAme $file_name"
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
echo "Current Time : $current_time"
new_fileName="${file_name}${current_time}.zip"
echo "New FileName: $new_fileName"
#echo $new_fileName ./app/code/community ./app/code/local ./app/design/frontend/indigo ./app/design/frontend/default
#zip $new_fileName ./app/code/community ./app/code/local ./app/design/frontend/indigo ./app/design/frontend/default
But for some reason I receive:
Init File NAme deploy
Current Time : 2015.10.01-16.04.02
./ManualPack.sh: line 5: $'\r': command not found
.zip5.10.01-16.04.02
I know its very very simple to any beginner in bash, but I tried for a decent amount of time, with many Stack Overflow threads to make it work, but the output remains the same.
You seem to have Windows styled line terminators in your file (\r\n). Converting the file with dos2unix should help.
This question already has answers here:
How do I remove the file suffix and path portion from a path string in Bash?
(15 answers)
Closed 7 years ago.
I have a few Java tests that I'd like to run by doing java <test-name>. But, all of the files are either .class or .java.
How do I trim off the end in a Bash script or in the terminal so that the command reads java <test-name>?
If you're using bash you can do the following
$ file="path/Foo.class"
$ echo "${file%.class}"
path/Foo