LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-23-2009, 04:41 AM   #1
ygdrazil
LQ Newbie
 
Registered: Aug 2008
Posts: 3

Rep: Reputation: 0
syntax error: unexpected end of file


Hi have a little code file to run a backup:

Code:
#!/bin/bash
today="$(date +%a-%d-%B-%Y)"
month="$(date +%b-%Y)"
file="/mnt/backupdir/backupdir/$month/"


if [ -d $file ]; then
     echo "folder OK"
else
	echo "foer lage folder"
        mkdir $file
	echo "laget folder"
fi

echo "over mysql dump"
mysqldump -u root -p5******** database > /mnt/backupdir/backupdir/$month/$today.database-backup.sql


cd /srv/www/appfolder/
tar czf /mnt/backupdir/backupdir/$month/$today.attachments-backup.tar.gz attachments

This have worked on the old server but now I get:
Quote:
sh /home/scrips/backupscript2
: command not foundscript2: line 5:
: command not foundscript2: line 6:
/home/scrips/backupscript2: line 21: syntax error: unexpected end of file
Have tried to search for a solution, but found no match that helped me.

regards and thanks for help!!!
 
Old 07-23-2009, 04:53 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
There is no syntax error. Maybe have you edited the file in windows? If this is the case it can be a problem with carriage returns which are not interpreted correctly by the shell. You can easily verify that using:
Code:
$ head -1 backupscript2 | od -c
0000000   #   !   /   b   i   n   /   b   a   s   h  \r  \n
0000014
The extra carriage returns can be removed using:
Code:
$ dos2unix backupscript2
 
1 members found this post helpful.
Old 07-23-2009, 04:58 AM   #3
ygdrazil
LQ Newbie
 
Registered: Aug 2008
Posts: 3

Original Poster
Rep: Reputation: 0
yupp, that did the trick!

Thanks a bunch!!
 
Old 07-23-2009, 05:00 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You're welcome!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script -----------syntax error: unexpected end of file ArthurHuang Programming 2 05-01-2009 10:29 AM
Bash script - syntax error: unexpected end of file Mr Pink Programming 7 12-19-2008 06:31 AM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM
/usr/bin/lesspipe: line 223: syntax error: unexpected end of file fakie_flip Linux - Software 1 09-06-2006 02:22 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration