Sign in to follow this  
Followers 0
JamesDover

Run Command

5 posts in this topic

#1 ·  Posted (edited)

I have looked every were and i know this is easy but how do i space variables so they don't crowd switches.

Run(@ComSpec & " /c mysqldump.exe" & " -u root -pxxxxx " & $Backuptype & $Database & " > " & $Database & "_" & $Trim & "_" & @YEAR & @MON & @MDAY & ".sql", @ScriptDir, @SW_HIDE)

The -pxxxxx "& $Backuptype & crowd like this -pxxxxx--opt

Cheers

Edited by JamesDover

Share this post


Link to post
Share on other sites

Maybe this isn't possible?

Share this post


Link to post
Share on other sites

I have looked every were and i know this is easy but how do i space variables so they don't crowd switches.

Run(@ComSpec & " /c mysqldump.exe" & " -u root -pxxxxx " & $Backuptype & $Database & " > " & $Database & "_" & $Trim & "_" & @YEAR & @MON & @MDAY & ".sql", @ScriptDir, @SW_HIDE)

The -pxxxxx "& $Backuptype & crowd like this -pxxxxx--opt

Cheers

I don't get it. The only crowding I see is between "--opt" and the database name because that's the way you specified it with "$Backuptype & $Database" vice "$Backuptype & ' ' & $Database".

So I don't see your issue, but you might consider StringFormat() to help it out:

$sUser = "root"
$sPass = "xxxxx"
$Backuptype = "--opt"
$Database = "MyDatabase"
$Trim = "Trim"
$sFormatString = "%s /c mysqldump.exe -u %s -p%s %s %s > %s_%s_%s%s%s.sql"

$sExtCmd = StringFormat($sFormatString, @ComSpec, $sUser, $sPass, $Backuptype, $Database, $Database, $Trim, @YEAR, @MON, @MDAY)
; Run($sExtCmd, , @ScriptDir, @SW_HIDE)
ConsoleWrite("Debug: " & $sExtCmd & @LF)

$sExtCmd = @ComSpec & " /c mysqldump.exe" & " -u root -pxxxxx " & $Backuptype & $Database & " > " & $Database & "_" & $Trim & "_" & @YEAR & @MON & @MDAY & ".sql"
ConsoleWrite("Debug: " & $sExtCmd & @LF)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Excellent I'll give it a go.

Cheers

I don't get it. The only crowding I see is between "--opt" and the database name because that's the way you specified it with "$Backuptype & $Database" vice "$Backuptype & ' ' & $Database".

So I don't see your issue, but you might consider StringFormat() to help it out:

$sUser = "root"
$sPass = "xxxxx"
$Backuptype = "--opt"
$Database = "MyDatabase"
$Trim = "Trim"
$sFormatString = "%s /c mysqldump.exe -u %s -p%s %s %s > %s_%s_%s%s%s.sql"

$sExtCmd = StringFormat($sFormatString, @ComSpec, $sUser, $sPass, $Backuptype, $Database, $Database, $Trim, @YEAR, @MON, @MDAY)
; Run($sExtCmd, , @ScriptDir, @SW_HIDE)
ConsoleWrite("Debug: " & $sExtCmd & @LF)

$sExtCmd = @ComSpec & " /c mysqldump.exe" & " -u root -pxxxxx " & $Backuptype & $Database & " > " & $Database & "_" & $Trim & "_" & @YEAR & @MON & @MDAY & ".sql"
ConsoleWrite("Debug: " & $sExtCmd & @LF)

:)

Share this post


Link to post
Share on other sites

It worked perfectly

Output:

Debug: C:\windows\system32\cmd.exe /c mysqldump.exe -u root -pxxxxx --opt database > database_opt_20080527.sql Correct one

Debug: C:\windows\system32\cmd.exe /c mysqldump.exe -u root -pxxxxx --optdatabase > database_opt_20080527.sql My old one

Cheers :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0