title: how to Pass php variables to a windows batch file
body: <p>I want to execute my batch file through php with passing some values from php to batch file.the purpose of batch file is to export csvs files to ftp.by commandline it works perfectly but not with php.given below is my batch and php files</p>
  
  <p><strong>test.bat</strong></p>
  
  <pre><code>@echo off
  set ftp_domain=%1
  echo FTP Domain to Connect to %ftp_domain%
  set ftp_username=%2
  echo FTP User Name %ftp_username%
  set ftp_password=%3
  echo FTP Password %ftp_password%
  set data_folder=%4
  echo Folder to upload Files from %data_folder%
  del ftpscript.txt
  echo open %ftp_domain%&gt;&gt;ftpscript.txt
  echo %ftp_username%&gt;&gt;ftpscript.txt
  echo %ftp_password%&gt;&gt;ftpscript.txt
  echo !:--- LOGGED INTO FTP --- &gt;&gt;ftpscript.txt
  echo pwd &gt;&gt;ftpscript.txt
  echo !:--- CHANGE DIRECTORY TO MAGENTO-CONNECTOR FOLDER ---&gt;&gt;ftpscript.txt
  echo cd Magento-Connector&gt;&gt;ftpscript.txt
  echo !:--- CHANGE DIRECTORY TO DATA FOLDER ---&gt;&gt;ftpscript.txt
  echo cd data&gt;&gt;ftpscript.txt
  echo !:--- SET LOCAL DATA DIRECTORY FOR FILE UPLOAD ---&gt;&gt;ftpscript.txt
  echo lcd %data_folder%&gt;&gt;ftpscript.txt
  echo !:--- SET FILE TRANSFER MODE TO BINARY ---&gt;&gt;ftpscript.txt
  echo binary&gt;&gt;ftpscript.txt
  echo !:--- RECURSIVELY UPLOAD FILES ---&gt;&gt;ftpscript.txt
  echo mput "*.csv"&gt;&gt;ftpscript.txt
  echo !:--- LIST OF FILES UPLOADED INTO FTP ---&gt;&gt;ftpscript.txt
  echo dir&gt;&gt;ftpscript.txt
  echo !:--- DISCONNECT ---&gt;&gt;ftpscript.txt
  echo disconnect&gt;&gt;ftpscript.txt
  echo !:--- EXIT FTP ---&gt;&gt;ftpscript.txt
  echo bye&gt;&gt;ftpscript.txt
  echo Start Login to FTP Server
  ftp -i -s:ftpscript.txt
  echo Delete FTP SCRIPT FILE
  del ftpscript.txt
  echo End of Operation....exiting....
  </code></pre>
  
  <p><strong>php file</strong></p>
  
  <pre><code>&lt;?php
  $var1 = "domain.com"; //this is domain
  $var2 = "username";   //this is username
  $var3 = "password";    //this is username
  $var4 = "C:\myCSV_FolderPath";
  $bat_file = "test.bat".escapeshellarg($var1)." ".escapeshellarg($var2)." ".escapeshellarg($var3)." ".escapeshellarg($var4);
  $output = null;
  exec($bat_file, $output);
  ?&gt;
  </code></pre>
  
  <p>when I run my php file it won't give any result and my csv files also not transfer to ftp.</p>