1

I'm having problems creating an automated script to isntall solr on a new server

sudo cp "apache-solr-3.3.0/dist/apache-solr-3.3.0.war" "/var/lib/tomcat6/webapps/solr.war"
sudo cp -R "apache-solr-3.3.0/example/solr/" "/var/lib/tomcat6/solr/"
sudo cp "solr.xml" "/etc/tomcat6/Catalina/localhost/solr.xml"
rm -R "apache-solr-3.3.0"
sudo service tomcat6 restart

I get

cp: target `\r' is not a directory
cp: target `\r' is not a directory
rm: cannot remove `\r': No such file or directory
 * Usage: /etc/init.d/tomcat6 {start|stop|restart|try-restart|force-reload|status}

It seems because I use line breaks to terminate the commands (as if it were a windows bat file). How do I run multiple commands in a single file

0

3 Answers 3

7

You are probably using Windows line breaks in your script. Convert them to Linux line breaks with the dos2unix utility: dos2unix your_script.sh

Sign up to request clarification or add additional context in comments.

1 Comment

or with dos2unix I used cat oldfild | tr '\n\r' '\n\n' >> newfile
2

The issue appears to be that your shell script has windows line endings (\r\n). Bash only cares about the \n and so the \r is interpreted as being a part of the command.

You need to change the line endings to unix (\n only). dos2unix can do this for you.

Comments

1

Correct the line endings in your script to use the unix standard \n. Unfortunately you have \rs there as well and it looks like the shell passes them as last arguments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.