Sign in to follow this  
Followers 0
ethnarch

Can't send command line arguements to program

9 posts in this topic

#1 ·  Posted (edited)

i am using a program called wput(well i actually started with the built in command line ftp in windows but i got the same problem)

I am basically trying to pass a file name to it via a dos prompt and upload the file however it keeps skipping the file. The bizarre part is that if i type the exact same thing i am passing by hand it uploads the file no problems only when i use the Send() command in auto does it skip the file.

my autoit code:

CODE
Func uploadFileWput($fileName)

Dim $ftpSettings = readFTPSettings()

sleep(2000)

If FileExists($fileName) Then

Else

MsgBox(4096,"", "does not exist.")

Sleep(5000)

EndIf

;Runwait(@ComSpec & " /c " & "wput.exe ftp://" & $ftpSettings[1] &":"& $ftpSettings[2]&"@"&$ftpSettings[0]& " " & $fileName & " ", "")

;Runwait("wput.exe ftp://" & $ftpSettings[1] &":"& $ftpSettings[2]&"@"&$ftpSettings[0]& " " & $fileName & " ", "")

Run("cmd", "")

Send(" wput.exe --verbose ftp://" & $ftpSettings[1] &":"& $ftpSettings[2]&"@"&$ftpSettings[0]& " " & $fileName & @LF & @CR)

;Send("{Enter}")

Dim $i = 0

Dim $cnt = 0

Do

AutoItSetOption("WinTitleMatchMode", 2)

if(WinExists("wput")=1)Then

$i = 1

EndIf

if($cnt > 5) Then

Break

EndIf

$cnt += 1

Until $i > 0

if($i = 0) then

msgbox(0, "FTP Error", "Upload Timed Out",10)

writeToLogFile("FTP Error Upload Timed Out")

return 0

EndIf

return 1

EndFunc

output of wput

CODE
C:\KSXReader>wput.exe --verbose ftp://user:pass@www.somesite.com mailbox\out\1_Midvale_07020

11302.xml

--13:03:05-- `mailbox/out\1_Midvale_0702011302.xml'

=> ftp://user:xxxxx@somesite:21/mailbox/out/..._0702011302.xml

Connecting to somesite:21... connected# --------- Welcome to Pure-FTPd [privsep] [TLS] -------

---

# You are user number 6 of 50 allowed.

# Local time is now 11:03. Server port: 21.

# This is a private system - No anonymous login

!

==> AUTH TLS ... failed (This security scheme is not implemented).

Logging in as user ... # User user has group access to: 12106

Logged in!

==> CWD mailbox/out

==> SIZE 1_Midvale_0702011302.xml ... failed.

Skipping this file due to resume/upload/skip rules.

-- Skipping file: mailbox/out\1_Midvale_0702011302.xml

# Goodbye. You uploaded 0 and downloaded 0 kbytes.

FINISHED --13:03:08--

Skipped 1 file.

now if i just type this physically in the command prompt it works fine:

wput.exe --verbose ftp://user:pass@www.somesite.com mailbox\out\1_Midvale_0702011302.xml

everything works fine and it uploads. I thought maybe it had something to do with the file maybe not existing but as you can see i am checking to see if the file exists now and that is not a problem either

thanks for the help

Edited by ethnarch

Share this post


Link to post
Share on other sites



Do you have spaces in the parameter you want to send... might wrap that parameter in Double Quotes to see if it rectifies the issue.


[center]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.[/center]

Share this post


Link to post
Share on other sites

i tried this like you said and no luck wput didn't even recognize the parameters this time.

C:\KSXReader>wput.exe --verbose 'ftp://username:password@www.something.com' 'mailbox\out\1_Midvale_07

02020705.xml'

Nothing done. Try `wput --help'.

then i tried this:

C:\KSXReader>wput.exe --verbose 'ftp://username:password@www.something.com mailbox\out\1_Midvale_0702

020700.xml'

Nothing done. Try `wput --help'.

I think it has something to do with the way that autoit terminates lines because if i type this

wput.exe --verbose ftp://user:pass@www.somesite.com mailbox\out\1_Midvale_07020

11302.xml

it works fine and the file gets uploaded, it only fails when i use run() or send() through autoit(with the same exact text i even double checked to make sure by copying and pasteing the auto it text that was outputted and it worked).

Share this post


Link to post
Share on other sites

Shell Execute??

No luck with shell execute either, or i can't really tell because i can't see the error messages that may or may not appear is there a way to catch the output of the console when using shellexecute?

Another thing which i payed little attention to is this line in the original output:

==> SIZE 1_Midvale_0702011302.xml ... failed.
Skipping this file due to resume/upload/skip rules.

i tried putting another command in the line --reupload like this

wput.exe --verbose --reupload 'ftp://username:password@www.something.com mailbox\out\1_Midvale_0702
020700.xml'

and it has some more output:

==> SIZE 1_Midvale_0702020847.xml ... failed.
Remote file size is equal to local size. Restarting at 0
==> TYPE I ... done.
==> PASV ... done.
==> STOR 1_Midvale_0702020847.xml ... done.

This file however does not exist as everytime i run the app i am using the time to generate a unique file, in addition to the fact i looked on the ftp server and nothing is there i deleted all the files.

I also tried putting a longer Sleep of about 20 seconds thinking maybe the file wasn't finished being written or something but that didn't help either

Share this post


Link to post
Share on other sites

oh yeah this is where i got that commmand from

−u

−−reupload

If this flag is specified, a remote file having the same size as the local one is to be uploaded. Skipping is default.

−−skip−larger

If this flag is specified, a remote file being larger than the local one will be skipped. Default is reuploading it.

−−skip−existing

If this flag is specified, the upload of a file will be skipped if the remote file already exists.

and if anyone wants to give my code a try here is the site for wput

Wput SourceForge

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

ugh i feel really stupid now,

i should have showed you guys where i was calling the function from, i was missing fileClose()

I stupidly never even tried to open the files there was nothing in them hehe which is why it wasn't uploading anything. The file was 0 kbytes.

so i changed this

;create file to put string created above in
        Dim $file = FileOpen ( "C:\Reader\mailbox\out\"&$locationSettings[1]&"_"&$locationSettings[0]&"_"&$fileNameDate&".xml", 2 )
        If $file = -1 Then
            writeToLogFile("could not open file for writing")
        Else
    ;write file to disk
            $file, $genValArr )
        EndIf

to this:

;create file to put string created above in
        Dim $file = FileOpen ( "C:\Reader\mailbox\out\"&$locationSettings[1]&"_"&$locationSettings[0]&"_"&$fileNameDate&".xml", 2 )
        If $file = -1 Then
            writeToLogFile("could not open file for writing")
        Else
    ;write file to disk
            if(FileWrite ( $file, $genValArr )=0)Then
                writeToLogFile("could not write file")
            Else
                FileClose($file)
            EndIf
        EndIf

now everything is happy hehe, thanks for the help everyone

Edited by ethnarch

Share this post


Link to post
Share on other sites

Thats why I have this picture to remember me of my own mistakes :)

Posted Image


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

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