Hello, i'm fairly new to scripting, so please bear with me (I did try looking this up first, i figured it had to have been asked already).
#!/bin/bash
fileName=`date | sed -n 's/ /_/g p' | sed -n 's/^/Backup_/p' | sed -n 's/$/\.tar/p'`; #THIS SETS BACKUP_DATE
echo $fileName #TEST OF VALUE
tar -cf $fileName tmp/*;
#gzip tmp/$fileName;
the test of the value (4th line) works, so i know its not something silly like my permissions screwed up for the script. I commented out the last line because for some reason when the script gets to the tar part (2nd to last line) it just hangs. hitting <ctrl>c the script ends, and there's no tar in my directory. what am i doing wrong?
thanks, i changed it to ./tmp/* just to be clear here - the v option is a good idea, but nothing shows still - just the hang
thanks, sed command (line 2) takes care of the white space output with the date program. I tried doing it without the dash infront of the options, and it still does exactly the same thing.
any other ideas? [i thought this would be a simple script, this is kind of frustrating :\( ]
interesting realization. on the Ubuntu 9.04 machine i tried this script with today (while writing it) i got the diagnostic-less hang I've mentioned above. with my macintosh Darwin terminal (OS X 10.5) i got some nasty errors:
rcmd: getaddrinfo: nodename nor servname provided, or not known
tar: Backup_Thu_May_14_15\:50\:11_EDT_2009.tar: Cannot open: Input/output error
tar: Error is not recoverable: exiting now
with the Free BSD server I've been telnet-ing into today (my college's server) this script works perfectly.
i even made sure (when the scripts run in the different systems) to check:
$ type bash
bash blah blah /proper/file/path/bash
so as to properly change the first line in my script.
i'm not sure why it only works in my school's server, but in case anyone has the experience/know-how... here's some info (don't know if its useful):
uname -a
FreeBSD school.domain.edu 7.0-RELEASE-p5 FreeBSD 7.0-RELEASE-p5 #1: Sun Oct 5 13:25:04 EDT 2008 bbroder@school.domain.edu:/usr/src/sys/amd64/compile/SCHOOL amd64