-   Linux - Server (
-   -   Question Mark appended to the end of file names (

mts7 09-15-2008 02:32 AM

Question Mark appended to the end of file names
I'm not sure if this is the right place for this thread, but here it is.

I do a database backup through the shell and write the dump to a file, but the file names end up looking like db1.sql?, db2.sql?, db3.sql. :'( When I include the proper files names in a cron job for tar (doing a site backup), the tar doesn't complete because it can't find those files.

Why are there question marks at the ends of the file names?

How can I get my script to not generate or fix the question marks?

code inside my sh file...
mysqldump -uuser_name 4 -ppassword --opt db1 > /home/user/logs/db1.sql
mysqldump -uuser_name 4 -ppassword --opt db2 > /home/user/logs/db2.sql
mysqldump -uuser_name 4 -ppassword --opt db3 > /home/user/logs/db3.sql

The cron job executes a php script that executes that shell script and then executes the tar.

Any help would be greatly appreciated. Thanks. :-D


chrism01 09-15-2008 03:32 AM

How did you create the shell file? Was it on an MS box?
There should be a space between -u and username value. What is the '4' doing there?

mts7 09-15-2008 11:56 AM

Yes, I created it on Windows. I actually copied the script from somewhere on the Internet. It works great with just one file. The 4 was leftover from my user name... I forgot to get rid of that part, too. I changed the script to have a space between the user name and password flags and values. Do these things have to do with the question marks?

chrism01 09-15-2008 08:57 PM

MS uses a different line-ending sequence (\r\n) to Unix/Linux (\n). This causes issues.
You can use the (Unix) util dos2unix to convert the file.

Here's the doc for mysqldump.

Note that usually there is a space between the flag and the value eg -u username, but -p is an exception, there should be no space, thus: -ppasswd
See the link I gave you.

PS Please add your distro to your profile so we can see it, and post the ver of MySQL as well.

mts7 09-18-2008 03:51 AM

Thanks for the quick response. :-) I added the dos2unix program to my script and it seems to be working the way I expect. Thanks. :-D I have dos2unix in the script in case I change the sh file on my Windows box.

I changed the mysqldump stuff like you mentioned and was listed in the manual. I think it was the \r\n stuff that was appending ? to all of the sql files. Adding that program call seemed to work just fine.

mysql 5.0.51a is the version installed on the server.

Thanks again for the help!


chrism01 09-18-2008 08:41 PM

My recommendation, edit Linux files on Linux, MS files on MS.

Saves on the ftp/scp as well.

All times are GMT -5. The time now is 10:30 PM.