Sign in to follow this  
Followers 0
Riaan

Not sending "password" in cmd windows - Server 2003 64bit

16 posts in this topic

CODE
Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/lunixDir/aFile.tgz " & $BackupDirectory & ".")

WinWaitActive(@ComSpec)

Sleep(1500)

Send("aPassword{ENTER}")

WinWaitClose(@ComSpec)

FileMove("extent0.tgz", "extent" & $MyDate[1] & "-" & $MyDate[2] & "-" & $MyDate[3] & ".tgz")

This is the part of the code that gives me the problem. It is used to copy from a Linux machine to a Windows as a backup procedure.

The AutoIt script is then put in the Scheduled tasks of Windows to ran at a specific time.

It does not Send the Password on line 4.

CODE
Send("aPassword{ENTER}"

and requires me to manually put it in.

On Windows XP, it seems to run fine.

I did recompile the script for 64bit as well and that did not help either.

Any help will be appreciated please.


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites



This Might Help ^^;

Send ('APassword')
Send ('{Enter}')

- John

Hey John, thank you for the prompt reply. I will try it out within the next two hours or so and let you know.

Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Hey John, thank you for the prompt reply. I will try it out within the next two hours or so and let you know.

I can not see why, but the script does not run at all. Also when compiling, it puts the password after the {ENTER}


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Hey John, thank you for the prompt reply. I will try it out within the next two hours or so and let you know.

Ok, found why it didn't run. I have a directory where pscp should be in and it was not removed, dont know why. Seems to be working like this on XP. Not tested on 64bit Server yet. Will post


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Ok, found why it didn't run. I have a directory where pscp should be in and it was not removed, dont know why. Seems to be working like this on XP. Not tested on 64bit Server yet. Will post

Still does not sent keystrokes in 64 bit windows 2003, even if I compile the script as 64 bit. This is a huge problem. If this can be sorted, everything will be ok. Here is my full code :

CODE
#include <Date.au3>

Dim $MyDate

Dim $MyTime

_DateTimeSplit(_NowCalc(),$MyDate,$MyTime)

$BackupDirectory = "f:\eSMS_databaseBackups\"

$ServerIP = "155.237.81.52"

$PCSPDir = "f:\pcsp\"

; Delete old Files

FileChangeDir($BackupDirectory)

DeleteOldFiles()

; Backup Latest

Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/opt/gemstone/product/seaside/data/backups/extent0.tgz " & $BackupDirectory & ".")

WinWaitActive(@ComSpec)

Sleep(1500)

Send("glass")

Sleep(700)

Send("{ENTER}")

WinWaitClose(@ComSpec)

FileMove("extent0.tgz", "extent" & $MyDate[1] & "-" & $MyDate[2] & "-" & $MyDate[3] & ".tgz")

; Functions

Func FileTimeToStr($value)

$value = $value[0] & "/" & $value[1] & "/" & $value[2]

Return $value

EndFunc

Func DeleteOldFiles()

$search = FileFindFirstFile("*.*")

; Check if the search was successful

If $search <> -1 Then

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$fileTime = FileTimeToStr(FileGetTime($file))

If _DateDiff('D',$fileTime,_NowCalcDate()) > 14 Then

FileDelete($file)

EndIf

WEnd

; Close the search handle

FileClose($search)

EndIf

EndFunc


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

CODE as discussed

CODE
#include <Date.au3>

Dim $MyDate

Dim $MyTime

_DateTimeSplit(_NowCalc(),$MyDate,$MyTime)

$BackupDirectory = "f:\eSMS_databaseBackups\"

$ServerIP = "155.237.81.52"

$PCSPDir = "f:\pcsp\"

; Delete old Files

FileChangeDir($BackupDirectory)

DeleteOldFiles()

; Backup Latest

Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/opt/gemstone/product/seaside/data/backups/extent0.tgz " & $BackupDirectory & ".")

WinWaitActive(@ComSpec)

Sleep(1500)

ControlSend (@ComSpec, '','','Glass')

Sleep(700)

ControlSend (@ComSpec, '','','{Enter}')

WinWaitClose(@ComSpec)

FileMove("extent0.tgz", "extent" & $MyDate[1] & "-" & $MyDate[2] & "-" & $MyDate[3] & ".tgz")

; Functions

Func FileTimeToStr($value)

$value = $value[0] & "/" & $value[1] & "/" & $value[2]

Return $value

EndFunc

Func DeleteOldFiles()

$search = FileFindFirstFile("*.*")

; Check if the search was successful

If $search <> -1 Then

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$fileTime = FileTimeToStr(FileGetTime($file))

If _DateDiff('D',$fileTime,_NowCalcDate()) > 14 Then

FileDelete($file)

EndIf

WEnd

; Close the search handle

FileClose($search)

EndIf

EndFunc


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Try compiling without UPX / and with 64 bit OS compilation.

What AutoIt version are you using?

Also, the code in post #7 looks like the same code you posted in post #6 which would mean you're bumping your thread in less than 24 hours. Please try to refrain from doing such things.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Try compiling without UPX / and with 64 bit OS compilation.

What AutoIt version are you using?

Also, the code in post #7 looks like the same code you posted in post #6 which would mean you're bumping your thread in less than 24 hours. Please try to refrain from doing such things.

the code is changed in #7 after ; Backup Latest.

Still does not work doing what you said.

using latest downloadable version.

Edited by Riaan

Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Try compiling without UPX / and with 64 bit OS compilation.

What AutoIt version are you using?

Also, the code in post #7 looks like the same code you posted in post #6 which would mean you're bumping your thread in less than 24 hours. Please try to refrain from doing such things.

You can spot the changes just past the first run line... I had to look very closely... :)

Cheers,

Brett

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Are you saying you've gotten it to work? (Not sure how to interpret "Code as discussed")

If not:

I don't have that OS to test on, but is the @COMSPEC the exact title of window you are looking for?

Did you try running this from just a standard command line first to verify it works before trying to do it progmatically?

Are you sure the output for this line:

:/opt/gemstone/product/seaside/data/backups/extent0.tgz

Should actually be this:

f:\pcsp\pscp.exe glass@155.237.81.52:/opt/gemstone/product/seaside/data/backups/extent0.tgz

? (The forward and back slashes have me confused)

When you say "Won't run", what part of the script won't run?

Have you put debug lines (message boxes, consolewrite, anything) in to see where exactly it fails at?

When using the "Run" function, it returns the Process Identification number (We refer to it as the PID),

Local $i_pid = Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/opt/gemstone/product/seaside/data/backups/extent0.tgz " & $BackupDirectory & ".")

MsgBox(64, "Info", $i_pid)

If that number is 0 Then it failed.

Edit:

Also remember that cmd.exe has an issue with spaces.

If this line is 100% correct to you:

Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/opt/gemstone/product/seaside/data/backups/extent0.tgz " & $BackupDirectory & ".")

Try this:

Run('"' & @ComSpec & '" /c "' & $PCSPDir & "pscp.exe glass@" & $ServerIP & ':/opt/gemstone/product/seaside/data/backups/extent0.tgz" "' & $BackupDirectory & '".')

Encasing paths in quotes generally helps to avoid space (interpreted as a new parameter) issues.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Are you saying you've gotten it to work? (Not sure how to interpret "Code as discussed")

If not:

I don't have that OS to test on, but is the @COMSPEC the exact title of window you are looking for?

Did you try running this from just a standard command line first to verify it works before trying to do it progmatically?

Are you sure the output for this line:

:/opt/gemstone/product/seaside/data/backups/extent0.tgz

Should actually be this:

f:\pcsp\pscp.exe glass@155.237.81.52:/opt/gemstone/product/seaside/data/backups/extent0.tgz

? (The forward and back slashes have me confused)

When you say "Won't run", what part of the script won't run?

I have done the procedure in the command line, and it works, always, no problem.

When i said it wont run, I actually ment that the script is still not working as it is suppose to. The problem i keep on having is that it doesnt sent the "glass" and {ENTER} keystrokes. If we run the script, it stoppes then the command windows opens. if the user then enters the password "glass", and press enter, everything below that works perfectly.

Hey thanks for all the help, i really appreciate it


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

Again we revert back to debugging or more information.

Are you sure it gets past WinWaitActive(@ComSpec)?

If so ... Replace ControlSend() with Send().


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Again we revert back to debugging or more information.

Are you sure it gets past WinWaitActive(@ComSpec)?

If so ... Replace ControlSend() with Send().

I added debugging everywhere, and all got a result > 0 on the info box. I changed the code as follows, and this seemed to worked better on XP. Compiled it normally and for 64bit as you indicated before. Will post the result for Server 2003 64 bit.

CODE
Run(@ComSpec & " /c " & $PCSPDir & "pscp.exe glass@" & $ServerIP & ":/opt/gemstone/product/seaside/data/backups/extent0.tgz " & $BackupDirectory & ".")

WinWaitActive(@ComSpec)

Sleep(300)

ControlSend (@ComSpec, '','','glass')

Sleep(100)

ControlSend (@ComSpec, '','','{Enter}')

WinWaitClose(@ComSpec)

FileMove("extent0.tgz", "extent" & $MyDate[1] & "-" & $MyDate[2] & "-" & $MyDate[3] & ".tgz")

If so ... Replace ControlSend() with Send().

.

This did not seem to work.

Edited by Riaan

Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

New problem, the script runs like a dream on Windows Server 2003 64 bit when I execute the .exe - I added the .exe to a Windows scheduled task. On the time that the task is suppose to run, it shows in the Scheduled task windows that it is running, but its not really. Could this be a problem with the Windows task scheduler??


Riaan van AardeintGo.net Software Development House

Share this post


Link to post
Share on other sites

I got a way to get the script to run flawless now. Even in the Windows scheduled tasks.

Made another very small script that calls the original script.

Thanks to everyone for all the help and effort. Much appreciated.

CODE
$ScriptDir = "F:\pcsp\"

; initialize backup procedure

Run($ScriptDir & "backupDatabase.exe")

Sleep(1500)


Riaan van AardeintGo.net Software Development House

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