|
Answer» hi all i had created a bat file by the example code given here to take the dump back up but by executing the bat its show the error my bat file code is @echo off echo Press any key pause>nul echo what is your username? set /p user= echo what is your password? set /p pass= If '%user%'=='xxxxx' goto gooduser echo WRONG USERNAME AND PASSWORD echo Press a key to exit pause>nul :gooduser If '%pass%'=='yyyyyy' goto good echo WRONG PASSWORD echo Press a key to exit pause>nul :good SET DD=%DATE:~7,2% SET MM=%DATE:~4,2% SET YYYY=%DATE:~10,4% SET HH=%TIME:~0,2% SET MN=%TIME:~3,2% SET SS=%TIME:~6,2% SET FOLDER=%YYYY%-%MM%-%DD% md C:\backsvvv%FOLDER% set dir=c:\backsvvv\%FOLDER% echo %dir%
mysqldump -u %user% -p%pass% --host=123.456.789.123 -r %dir%\myDbfromvvv.sql student
echo VERY GOOD pause
by executing this is the error Press any key what is your username? xxxxxxx what is your password? yyyyyyyy c:\backsvvv\2009-08-04 mysqldump: Can't create/write to file 'c:\backsvvv\2009-08-04\myDbfromvvv.sql' ( Errcode: 2) VERY GOOD Press any key to continue . . .
but the same code execute with the cmd C:\Documents and Settings\PROGR>mysqldump -u xxxxxx -pyyyyyyy --host=123.456.789.123 -r c:\backsvvv2009-08-04\myDbfromvvv.sql students
will give the dump to the c:\backsvvv2009-08-04 \ folder
i had also given time so that if taking backup again and again the folder NAME will differ with time second pls help me what is the problem in my bat file Thanks in advance may sound strange but what name did you give the batch file? If the name is the same as one of the commands in the batch file then you will sometimes have problems.Just some things I noticed, When you're supposed to exit, you only put Pause>nul but you need to add exit after that. For your IF statements, use the /i switch so it isn't case sensitive. For the MD command, you need a \ before the %. (this may also solve your problem) thanks for your valuable replies the problem in the bat file was md C:\backsvvv%FOLDER% set dir=c:\backsvvv\%FOLDER%
there was a '\' after the backsvvv bau not in the md command
but still i'm facing another problem to make DIRECTORY as per the date if the back is taking on same date over writing problem may occur and the code will be displayed so i put the time append to date SET DD=%DATE:~7,2% SET MM=%DATE:~4,2% SET YYYY=%DATE:~10,4% SET HH=%TIME:~0,2% SET MN=%TIME:~3,2% SET SS=%TIME:~6,2% SET FOLDER=%YYYY%-%MM%-%DD%-%HH%-%MN%-%SS% echo %FOLDER% but another problem arise is if the time is 8 AM the output will be c:\backsvvv2009-08-05- 8-59-59 means the folder will not be created with backsvvv2009-08-05- 8-59-59 there is a gap after the date if is after noon then backsvvv2009-08-05-13-59-59 it will be ok so how iwill append a zero before the time if time is less than 12 and is there any way to hide the password,and if the password is wrong then also the goto is working how can i exit from that and show the password is not correct pls help me thank you
|