- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: error in script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 03:12 AM
тАО09-06-2005 03:12 AM
./backupcdr: line 49: syntax error: unexpected end of file
please help!!
#!/bin/bash
cd /home/test
#
filename=/home/backup.`date '+%d.%m.%Y.%k.%M.%S'`.tar
indexfile=/home/backup.`date '+%d.%m.%Y.%k.%M.%S'`.txt
ls -l /home/test >$indexfile
mkdir -p /home/backup-tijd
for file in $(ls *.test); do
mv ${file} /home/backup-tijd
done
cd /home/backup-tijd
tar cvf $filename .
if [ $? -ne 0 ];
then echo "tar failed"
exit 0
else
echo тАЬtar okтАЭ
fi
gzip $filename
if [ $? -ne 0 ];
then echo "gzip failed"
exit 1
else
echo тАЬgzip okтАЭ
if
exit 0
exit 1
Solved! Go to Solution.
- Tags:
- bash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 03:22 AM
тАО09-06-2005 03:22 AM
Re: error in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 05:35 AM
тАО09-06-2005 05:35 AM
Re: error in script
The if needs to be a fi at the end of your script. Also to re-iterate, there is no need for exit 0, exit 1.
The exit 0 signafies that the script has finished with no errors. The exit 1 signafies that the script has exited with an error. I see in your script that you have echo "tar failed", then right after that you have exit 0. That should be an exit 1 to signify that there was an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 05:54 AM
тАО09-06-2005 05:54 AM
Re: error in script
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 05:57 AM
тАО09-06-2005 05:57 AM
Re: error in script
if [ -s $( ls ) ]
then
tar cvf $filename *
gzip $filename
exit 0
else
echo "No file created"
exit 1
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 05:58 AM
тАО09-06-2005 05:58 AM
Re: error in script
Hi,
I would suggest some modifications (last part of the script).
cd /home/backup-tijd
if [ -s $( ls ) ]
then
tar cvf $filename *
gzip $filename
exit 0
else
echo "No file created"
exit 1
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 06:13 AM
тАО09-06-2005 06:13 AM
Re: error in script
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2005 06:17 AM
тАО09-06-2005 06:17 AM
Re: error in script
wc -l ./backupcdr
it means that there is a mismatching if-then-else or for/while/until-do-done construct, which reinforces the incorrect if/fi.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 02:46 AM
тАО09-07-2005 02:46 AM
Re: error in script
I want to use the exit to exit the script doesn├в t it work that way? Is the exit 0 only the error output?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 02:57 AM
тАО09-07-2005 02:57 AM
Re: error in script
Also, double-check all your quotation and backtick marks. I've seen this error caused by having unmached quotes.
Regards,
Mark