Jump to content

variable in @ComSpec


Recommended Posts

Hi I am trying to run a command from @ComSpec with a Variable in the syntax.

 

At the moment is this mycode:

RunWait(@ComSpec & " /c " & 'c:\bfretail\mysql\bin\mysql.exe -u"root" -p"*******" -h"localhost" -e"select count(*) from sessie where ss_datum >= ''2015-01-01'';" -Dbnfdta > C:\Temp\sessies.txt', "", @SW_HIDE)

Where I want to edit the command to automaticly find the year minus 1 like this:

Global $YEAR = @YEAR - 1

RunWait(@ComSpec & " /c " & 'c:\bfretail\mysql\bin\mysql.exe -u"root" -p"*******" -h"localhost" -e"select count(*) from betaling where bl_datum >=' & $YEAR & '-01-01'';" -Dbnfdta > C:\Temp\betaalregels.txt', "", @SW_HIDE)

But how do i create the right command syntax to use this?

Link to comment
Share on other sites

I believe that this is easier:

RunWait(@ComSpec & " /c " & 'c:\bfretail\mysql\bin\mysql.exe -u"root" -p"*******" -h"localhost" -e"select count(*) from betaling where bl_datum >=' & (@YEAR - 1) & '-01-01'';" -Dbnfdta > C:\Temp\betaalregels.txt', "", @SW_HIDE)

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • Developers

Assume you are having issues with what you posted? :)

When you need single quotes around the date, you are missing  the start single quote. Guess this should work:

RunWait(@ComSpec & " /c " & 'c:\bfretail\mysql\bin\mysql.exe -u"root" -p"*******" -h"localhost" -e"select count(*) from betaling where bl_datum >=''' & $YEAR & '-01-01'';" -Dbnfdta > C:\Temp\betaalregels.txt', "", @SW_HIDE)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...