Dennis Carr ([info]dennisthetiger) wrote in [info]debian,
@ 2007-12-24 21:21:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Probably more of a bash question....
OK, so I have a backup script that an associate of mine wrote. The problem is that the backup script, which exports database files from MySQL, won't dump them - I get the following response:

/home/dennis/bin/backup-export: line 21: ${backupdir}/rf_forums_$TODAY: ambiguous redirect

The command in question is as follows:

mysqldump -u(redacted!) -p(redacted!) --host=127.0.0.1 rf_forums > ${backupdir}/rf_foru\
ms_$TODAY

...note, a similar command is run thrice in this script.

The confusion is that this worked when I first ran the file. On the other hand, I was root when I first ran the backup script. At this moment, I don't have any access to the root end o' things. So that said, does anyone have any insight as to what's going on? Perhaps I should rewrite the script?

...Bueller?


(Post a new comment)


[info]moonlit_me
2007-12-25 06:11 am UTC (link)
Are both ${backupdir} and $TODAY well-defined? hmm... or maybe using ${TODAY} instead? (I know sometimes bash has trouble identifying variables without that, though I think it only matters if you have something following the "TODAY" variable name...)

Try echoing the variables to someplace you can read them, mayhaps, to see what bash things they are. Or hard-coding them and see if it still calls it an ambiguous redirect. Are there any special characters in the username or pass that could be confusing bash?

(Reply to this)(Thread)


[info]dennisthetiger
2007-12-25 07:25 am UTC (link)
Both $backupdir and $TODAY are, indeed, well defined. $TODAY is based on output from date(1), and $backupdir is a hard directory with $TODAY at the end.

I also have checked the output, and the variable is set as "TODAY=`date +___%b_%d_%Y__%l_%M%P.sql`". I'm wondering then if the underbars are perhaps causing this - does bear the question, now that I'm also coherent. =^^=

A side note, as far as running as root, I recall running this as myself as well, successfully.

(Reply to this)(Parent)


[info]halkeye
2007-12-25 06:31 am UTC (link)
stupid question, but if it worked as root, but not now, could it be that you can't write to backupdir as your user?

(Reply to this)(Thread)


[info]dennisthetiger
2007-12-25 07:19 am UTC (link)
No, because in that case, I'd get 'access denied'.

(Reply to this)(Parent)(Thread)


[info]halkeye
2007-12-25 03:59 pm UTC (link)
have you tried sh -x or set -x?
its good for debugging what exactly is happening.

(Reply to this)(Parent)


[info]safiiru
2007-12-25 07:28 am UTC (link)
I haven't encountered exactly this error, my bet is that bash is confused about whether you mean the command as you probably do or with a single ">$" redirect - I know spaces can be optional in some places that you really wouldn't expect. I'd try quoting the second command and seeing if that solves the problem. (Note, however, that I'm not in a position to test this myself at the moment.)

(Reply to this)


[info]demonbane
2007-12-25 12:56 pm UTC (link)
About 30 seconds of googling later, here's what I've got:

http://www.linuxquestions.org/questions/programming-9/bash-returns-ambiguous-redirect-with-date-in-filename-276505/

Almost identical problem as yours. My guess would be that, as in that forum post, your date string is getting spaces instead of zeros, hence the problem. Could be wrong, but it just seemed like an identical issue to yours. Hope it helps.

(Reply to this)(Thread)


[info]gwillen
2007-12-26 02:55 am UTC (link)
I second this answer. This is the issue, right here.

(Reply to this)(Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…