Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have here the batch file in windows, I want to apply the same to linux. May I ask your help to run it in linux. Below is the batch file for windows:

@echo off

TITLE Upload Masterlist

set /p answer=Do you want continue? [Y/N]:

if %answer%==Y goto G
if %answer%==y goto G
if %answer%==N goto EndoF
if %answer%==n goto EndoF


set MYSQL_HOME=mysql>C:\xampp\mysql\bin\mysql.exe
set database_name=ppn
set user_name=root
set password=
set sql_file=C:\LEGAL_BACKUP\Masterlist.sql

%MYSQL_HOME% -u %user_name% -p %password% -D %database_name% < %sql_file%

echo. Uploading Masterlist is successfully done..............!

Thanks in advance,


share|improve this question

It looks like your batch file is designed to back up a MySQL database on the local machine. While it is possible to translate the .bat commands into equivalent bash commands, the names of the executables, the directories, etc. would all be different.

Instead, you might want to try MySQL-Maint, an open-source Linux-friendly bash script designed to do exactly what you are doing.

share|improve this answer
It's not a backup, it's an import (has <instead of >). The SQL file is loaded into the specified database. – onik Jan 25 '13 at 8:37
Ah my mistake. I believe MySQL-Maint can handle that too, but it may be overkill. – Travis G. Jan 25 '13 at 8:42

Try this:


read -p "Do you want to continue? " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
    exit 1


echo "Uploading Masterlist is successfully done..............!"

unset DB_NAME
unset DB_USER
unset DB_PASS
unset SQL_FILE
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.