Skip to main content
Participating Frequently
January 8, 2013
Question

Passing variables to command line script

  • January 8, 2013
  • 1 reply
  • 582 views

I have the following script that is meant to create a mysql database on a remote server using values passed into it:-

set arg1=\\192.168.0.254\e$\Program Files\MySQL\MySQL Server 5.5\bin  set arg2=192.168.0.254  set arg3=%1    echo %arg1%  echo %arg2%  echo %arg3%    pushd %arg1%  mysql -uignite -h %arg2% -p***** -e "CREATE DATABASE %arg3%"    pause

If I place a value in arg3 - i.e. MYDatabaseName, then the script runs and fine from a web page that use the following coldfusion code to call the script:-

<cfexecute name="fullpathtocmdfile\AddDatabase.cmd"  arguments="'MyDatabaseName'">  </cfexecute>

But if I keep the %1 in there - ie the holder for the variable - then it doesn't seem to pick it up and create the database.

Am I using the correct syntax to pass the variable into the file?

Any help greatly appreciated

Paul

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
January 13, 2013

What is you used "CREATE DATABASE "%arg3% in place of "CREATE DATABASE %arg3%"?