What it means /bin/bash^M: bad interpreter? [duplicate] - linux

This question already has answers here:
./configure : /bin/sh^M : bad interpreter [duplicate]
(15 answers)
Closed 4 years ago.
I create start.sh file and wont to start,but retruned me
./start.sh: /bin/bash^M: bad interpreter: No such file or directory
this is my start.sh file content
#!/bin/bash
cd /home/test/Desktop
node cron.js
How can I fixed this problem?

It means your script file has MSWin line endings. Use dos2unix or fromdos to fix them.

Related

Unable to copy files using Shell Script [duplicate]

This question already has answers here:
How to assign a glob expression to a variable in a Bash script?
(8 answers)
Wildcard within quotations
(3 answers)
Closed 8 months ago.
I am unable to copy files using Shell script. I validated in shellcheck.net no issues found in syntax.
It showing error as file not fount but I am using exact file name.
Below is my Shell script.
#! /bin/bash
export SOURCE_PATH="/home/la1122/export"
export SOURCE_TARGET="/home/la1122/export/backup"
FILE="*.dat"
cd $SOURCE_PATH
echo "Current location: $(pwd)"
cp "$FILE" "$SOURCE_TARGET"

.bat file is not executing on Linux server [duplicate]

This question already has an answer here:
Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
(1 answer)
Closed 6 years ago.
I've made a simple bat file "run_perl.bat" that executes a Perl script "Oncomine_main.pl" in \data\test_scripts directory.
Here is the content of the bat file:
cd /data/test_scripts
perl Oncomine_main.pl
I run the script from the login directory
Here is what is returned to me:
[username#path-twood3 ~]$ ./run_perl.bat
: No such file or directory /data/test_scripts
": No such file or directorymine_main.pl
Please suggest how to fix this issue?
Thank you
Add #!/bin/sh as the first line of run_perl.bat.

How to get full path of a file from another directory in shell script? [duplicate]

This question already has answers here:
How do you normalize a file path in Bash?
(24 answers)
Closed 6 years ago.
I've a shell script at
/home/abc/xyz/test.sh
I've a file at
/home/def/ghi/jkl/lmn/foo.txt
I'm running the scrip from /home as I've set my PATH variable to point to /home/abc/xyz/
I'm passing the relative path of foo.txt to my script like so test ./def/ghi/jkl/lmn/foo.txt
I want to capture the full path of foo.txt into a variable in my script, any pointers?
Tried https://stackoverflow.com/a/5265775 and https://stackoverflow.com/a/9107028/4468505 but in vain.
foobar=`readlink -f <passed in relative path to foo.txt>`

How to move to other directory with bash? [duplicate]

This question already has answers here:
How can I cd into a directory using a script?
(4 answers)
Closed 7 years ago.
My script
#!/bin/bash
for file in *.ats; do
mv $file /home/holmes/procmt
done
cd /home/holmes/procmt
All files are moved but I want to change my current directory to /home/holmes/procmt and nothing happens.WHY?
If i run script ./pch.sh,I stay in the same shell.
The shell running the script moved, but the shell you were typing in when you started the script stayed put. If you precede the name of your shell script with . (dot space) it will run in 'your' shell.

Executable file from R code [duplicate]

This question already has an answer here:
What are the ways to create an executable from R program
(1 answer)
Closed 8 years ago.
I'm a master student, and I've a little problem with a script written in R.
How can I produce an executable file from it?
Should I use Linux (e.g.Ubuntu) or windows? I wrote a code in Windows, but I can use Ubuntu.
Using linux, you can run your Rscript from the command line (in the terminal like this)
Rscript <name of your Rscript file>

Resources