Register
It is currently Tue Sep 30, 2014 5:55 pm

Extra Newlines, OSX


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 11, 2011 2:13 pm   

Joined: Fri Feb 11, 2011 2:03 pm
Posts: 4
Hi, first time posting here. I'm trying to write a simple script which automates the action of rendering a map of my Minecraft server, and saving the image to a directory, along with a scaled down copy of that image. I have programs (c10t for the mapping and ImageMagick for the scaling) to do both functions, but I can't get the script to work properly.

I need to include the time in the file name as the script is to be run automatically every X minutes. I have no problem getting the date, but when I try to append it into the file path (see code), I get extra newlines at the end, resulting in .png\n files, and Map-xxxx\n.png\n files. When I put all of the commands into a terminal window separately, everything works fine, and I am super confused by this. I'm clearly making some kind of error with the way I include the variables, but I've tried all sorts of formats with various sub-shells to no avail. Any Advice?


Code:
#!/bin/sh

DATE=$(date +%Y%m%d%H%M%S)
LARGE="/Library/WebServer/Documents/Maps/Large/Map-$DATE.png"      #Directory of the large images
SMALL="/Library/WebServer/Documents/Maps/Small/Map-$DATE.png"      #Directory for the thumbnails
MAP="/Users/XXXXXX/Documents/McMyAdmin/TranquilityBase"            #Target for the mapping software
c10t -w $MAP -o $LARGE -m 2 -M 256 -y -r 270               #invokes the mapper with various paramaeters
convert -resize 6% $LARGE $SMALL                        #makes a low res copy to $SMALL


Top
 Profile  
 PostPosted: Fri Feb 11, 2011 3:29 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
There is nothing wrong with the script, or the way you handle the variables. Everything is pretty much spot on.
If there are extra newlines in the filenames, they must be coming from somewhere else...


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP