• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Passing variables to command line script

New Here ,
Jan 08, 2013 Jan 08, 2013

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

534

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2013 Jan 13, 2013

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation