Paradox Posted January 24, 2006 Posted January 24, 2006 Me again... Still working on the same project, but am having limited success. The concept of what I'm trying to do now is (as I've mentioned before) do a large file transfer over a vpn via UNC paths. I'm at the point where I have a GUI box come up displaying the UNC location and filename as well as the file size, but what I'm toying with now is showing the amount of bytes currently transferred.I notice that in v3 there is an Inetget() function, but after reading about it some, it appears that you can only use that function with HTTP, HTTPS, and FTP protocals. Does anyone have an idea about how to go about finding what the amount transferred would be??My current copy command is: $pid = Run(@comspec & " /c " & $copy, @SW_HIDE) You can see that this is going to be something that I'll be using a do ... until not processexists($pid) loop for. The file being transferred is currently stored in a variable named $file2transferany help or point in the right direction would be greatly appreciated!!! Thanks!
BigDod Posted January 24, 2006 Posted January 24, 2006 If I understand correctly you are looking for FileGetSize or DirGetSize. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
Paradox Posted January 24, 2006 Author Posted January 24, 2006 If I understand correctly you are looking for FileGetSize or DirGetSize. No... not really... I'm already using the filegetsize() function to get the total file size... like this: $compresscomplete="compresscomplete.txt" while fileexists($compresscomplete)=0 sleep(30000) wend $file=fileopen($compresscomplete, 0) $file2transfer=filereadline($file) fileclose($file) $copy="copy " & $file2transfer & " " & @Scriptdir & "\" ;msgbox(0, "test", "Path to copy = " & $copy) $pid = Run(@comspec & " /c " & $copy, @SW_HIDE) guicreate("File Transfer in Progress") guictrlcreatelabel("File transfer in progress. This may take hours to complete.", 5, 5) guictrlcreatelabel("",5,15) guictrlcreatelabel("File being transferred : " & $file2transfer, 5, 25) guictrlcreatelabel("Total File size : " & filegetsize($file2transfer) & " bytes", 5, 40) ;insert either progress bar or text to display initial amount of transferred file here guisetstate(@SW_SHOW) Do ;insert updated amount of transferred file here. Do it until the process is no longer running. Until Not ProcessExists($pid) Because of the run(@comspec & " /c " & $copy, @sw_hide) command, the only thing that is displayed (without the @SW_HIDE) is a black box with a blinking cursor. When the file starts to transfer, if you pull up the properties of the file, it shows the full file size. So that's where my dilemma starts. If it were that it only displays the size of the file transferred (through windows) then yes, I would just use the FileGetSize() procedure... but, it just isn't going to work like that. Understand me now??? Sorry for any confusion...
ZeDMIN Posted January 24, 2006 Posted January 24, 2006 Well, you could write your own copy UDF with FileOpen, FileRead and FileWrite. Another option would be to use another copy program instead of the windows one. There are some copy programs out there which have some output about their status. Greetings, ZeD
Paradox Posted January 24, 2006 Author Posted January 24, 2006 Well, you could write your own copy UDF with FileOpen, FileRead and FileWrite.Another option would be to use another copy program instead of the windows one. There are some copy programs out there which have some output about their status.Greetings,ZeDYour right... I could. Here's something funn though: If I use the _FileCountLines() (with the intention of copying the file line by line) with a sample .RAR file (which I'm using as my compression method) it returns a value of "-1247530" lines... WTF is that about???
seandisanti Posted January 24, 2006 Posted January 24, 2006 Your right... I could. Here's something funn though: If I use the _FileCountLines() (with the intention of copying the file line by line) with a sample .RAR file (which I'm using as my compression method) it returns a value of "-1247530" lines... WTF is that about???if you exceed the bounds of a type, the numbers switch to negative; not sure if that's what's happening here because that would take a pretty big number, but it is possible. you could try to count the lines manually, writing the output to the console or a message box before the number resets...$file = FileOpen("blah.txt",0) $counter = 0 while 1 $line = FileReadLine($file) If @error Then ExitLoop If $counter + 1 > $counter Then $counter = $counter + 1 Else MsgBox(0,"Type overflow","Counter resetting after " & $counter) EndIf Wend
Paradox Posted January 24, 2006 Author Posted January 24, 2006 if you exceed the bounds of a type, the numbers switch to negative; not sure if that's what's happening here because that would take a pretty big number, but it is possible. you could try to count the lines manually, writing the output to the console or a message box before the number resets...$file = FileOpen("blah.txt",0) $counter = 0 while 1 $line = FileReadLine($file) If @error Then ExitLoop If $counter + 1 > $counter Then $counter = $counter + 1 Else MsgBox(0,"Type overflow","Counter resetting after " & $counter) EndIf Wend I suppose this could work, however, I tried it out and put in an addition 3 lines... something like this: $file2transfer="\\jfritzsche\dbbases\compressed.rar" $newfile="\\jfritzsche\dbbases\transferTest.rar" $file = FileOpen($file2transfer, 0) $file2 = fileopen($newfile, 2) $counter = 0 while 1 $line = FileReadLine($file) If @error Then ExitLoop If $counter + 1 > $counter Then $counter = $counter + 1 FileWriteLine($file2, $line) Else MsgBox(0,"Type overflow","Counter resetting after " & $counter) EndIf Wend msgbox(0, "test", "Amount of lines : " & $counter) The amount of lines returned is 6 thousand something, however, if I open the RAR file in question using notepad, it's only 1000 lines. Okay, this I could dismiss as just a glitch except for when it copies the file, it's not nearly the size it should be and is subsequently considered corrupt. If I open the file up using RAW mode, I get 0 lines in the orginal file, and a 0kbp file... This sucks....
Moderators SmOke_N Posted January 24, 2006 Moderators Posted January 24, 2006 I'm confused... Are you transferring .txt files or .rar files? 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.
seandisanti Posted January 24, 2006 Posted January 24, 2006 I'm confused... Are you transferring .txt files or .rar files?yeah, i don't think line by line on a rar file is a good idea...
Paradox Posted January 24, 2006 Author Posted January 24, 2006 I'm confused... Are you transferring .txt files or .rar files?It's an RAR file...
Paradox Posted January 24, 2006 Author Posted January 24, 2006 yeah, i don't think line by line on a rar file is a good idea...I'm not saying that it IS a good idea, but if you read back through the thread, I'm just trying to get some kind of information to appear in my script as to what is currently being transferred. The current solution that I have does nothing more than give me a big black box with a blinking cursor... I mean... the only way that I know right now that it's actually transferring a file is because of the network activity lights...
PsaltyDS Posted January 24, 2006 Posted January 24, 2006 I'm not saying that it IS a good idea, but if you read back through the thread, I'm just trying to get some kind of information to appear in my script as to what is currently being transferred. The current solution that I have does nothing more than give me a big black box with a blinking cursor... I mean... the only way that I know right now that it's actually transferring a file is because of the network activity lights...Can you do FileGetSize on the target file? Loop that and do the math to compare it wtih the source FileGetSize, and you can make a progress bar out of it. 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
Moderators SmOke_N Posted January 24, 2006 Moderators Posted January 24, 2006 Can you do FileGetSize on the target file? Loop that and do the math to compare it wtih the source FileGetSize, and you can make a progress bar out of it.I was going to say something similar, but I don't think you can use a progress bar with it... maybe a msgbox.If FileExists($EndFile) And FileGetSize($EndFile) >= FileGetSize($ThisFile) Then MsgBox(0, 'Ended', 'Transfer Complete') Maybe something like that. But I'm not getting a reading correcty using FileOpen() on a .rar file. 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.
PsaltyDS Posted January 24, 2006 Posted January 24, 2006 I was going to say something similar, but I don't think you can use a progress bar with it... maybe a msgbox. If FileExists($EndFile) And FileGetSize($EndFile) >= FileGetSize($ThisFile) Then MsgBox(0, 'Ended', 'Transfer Complete') Maybe something like that. But I'm not getting a reading correcty using FileOpen() on a .rar file. I was thinking more along the lines of: $ProgGUI = GUICreate("File progress", 200, 100) $ProgBar = GUICtrlCreateProgress(10, 10, 180, 25) $ProgLabel = GUICtrlCreateLabel("Download is 0% complete...", 10, 45) $SourceSize = FileGetSize($SourceFile); Get size of source file ; Insert code here to run whatever to start the file transfer... GUISetState(@SW_SHOW, $ProgGUI) While(1) $DestSize = FileGetSize($DestFile); Get size of destination file If $DestSize = $SourceSize Then GUIDelete($ProgGUI) MsgBox(32, "File progress", "Download complete.") ExitLoop Else $Progress = ($DestSize/$SourceSize)*100 GUICtrlSetData($ProgBar, $Progress) GUICtrlSetData($ProgLabel, "Download is " & $Progress & "% complete...") Sleep(1000) EndIf WEnd Keep doing the math and update a progress bar... until they are equal (or a timeout, if required). 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
Moderators SmOke_N Posted January 24, 2006 Moderators Posted January 24, 2006 (edited) If that's the case you could do something like this: http://www.autoitscript.com/forum/index.ph...ndpost&p=141934And use While FileGetSize($DestFile) < FileGetSize($SourceFile) instead of While @InetGetActive Edited January 24, 2006 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.
Paradox Posted January 25, 2006 Author Posted January 25, 2006 Can you do FileGetSize on the target file? Loop that and do the math to compare it wtih the source FileGetSize, and you can make a progress bar out of it.No, unfortunately, that won't work. When I tested out my original version, I had the opportunity to check the target file. As soon as it starts to copy, the system registers it as being the full file size... (in the case of what I was transferring -- 375 meg within seconds of beginning the download.).
PsaltyDS Posted January 25, 2006 Posted January 25, 2006 No, unfortunately, that won't work. When I tested out my original version, I had the opportunity to check the target file. As soon as it starts to copy, the system registers it as being the full file size... (in the case of what I was transferring -- 375 meg within seconds of beginning the download.).Ouch. That bites. Do you have any choice in transfer protocol or client software used to get the file? That's just not acceptable behavior from the system. 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
Paradox Posted January 25, 2006 Author Posted January 25, 2006 Ouch. That bites. Do you have any choice in transfer protocol or client software used to get the file? That's just not acceptable behavior from the system. Um... if you mean do I have the option of doing an FTP transfer or HTTP, No. I don't... My only options for method of transfer are limited by your basic networking file transfer... it's all UNC paths... If you have a viable solution that I can use rather than the standard copy command, or some direction for where to look, it would be greatly appreciated!
PsaltyDS Posted January 25, 2006 Posted January 25, 2006 Um... if you mean do I have the option of doing an FTP transfer or HTTP, No. I don't... My only options for method of transfer are limited by your basic networking file transfer... it's all UNC paths... If you have a viable solution that I can use rather than the standard copy command, or some direction for where to look, it would be greatly appreciated! Fixed it! Well, worked around it... Use 'type' instead of 'xcopy', 'copy', or AutoIT FileCopy, and you get the proper behavior for the destination file size. This command has no provision for the '/v' option, though so a file compare, or even better, use of MD5 sums should be added. The code below tested well for me:CODE; Test file copy...$SrcPath = "\\ServerName\ShareName"$DestPath = "C:\Temp"$FileName = "BigFatFile.rar"MsgBox(32, "Filecopy Test", "Click OK to begin copying" & @CRLF & _ $SrcPath & "\" & $FileName & " to " & $DestPath)$ProgGUI = GUICreate($FileName & " copy progress", 300, 80)$ProgBar = GUICtrlCreateProgress(10, 10, 280, 25)$ProgLabel = GUICtrlCreateLabel("Download is 0% complete...", 10, 45, 280, 25)$SourceSize = FileGetSize($SrcPath & "\" & $FileName); Get size of source file$TypeCommand = 'type "' & $SrcPath & '\' & $FileName & '" > "' & $DestPath & '\' & $FileName & '"'Run(@ComSpec & ' /c ' & $TypeCommand, $DestPath, @SW_SHOW)GUISetState(@SW_SHOW, $ProgGUI)While (1) Sleep(1000) $DestSize = FileGetSize($DestPath & "\" & $FileName); Get size of destination file If $DestSize = $SourceSize Then GUIDelete($ProgGUI) MsgBox(32, "File progress", "Download complete.") ExitLoop Else $Progress = Int(($DestSize / $SourceSize) * 100) GUICtrlSetData($ProgBar, $Progress) GUICtrlSetData($ProgLabel, "Download is " & $Progress & "% complete...") EndIfWEndI had never noticed Microsoft's bizzare behavior on the copy creating the destination file as full size before it even has the data - but I consider them slime anyway... As compensation for having to put up with their sorry crap, I hereby grant you permission to download, distribute, and install as many copies of Linux as you want - for life! 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
Paradox Posted January 25, 2006 Author Posted January 25, 2006 Fixed it! Well, worked around it... Use 'type' instead of 'xcopy', 'copy', or AutoIT FileCopy, and you get the proper behavior for the destination file size. This command has no provision for the '/v' option, though so a file compare, or even better, use of MD5 sums should be added. The code below tested well for me:CODE; Test file copy...$SrcPath = "\\ServerName\ShareName"$DestPath = "C:\Temp"$FileName = "BigFatFile.rar"MsgBox(32, "Filecopy Test", "Click OK to begin copying" & @CRLF & _ $SrcPath & "\" & $FileName & " to " & $DestPath)$ProgGUI = GUICreate($FileName & " copy progress", 300, 80)$ProgBar = GUICtrlCreateProgress(10, 10, 280, 25)$ProgLabel = GUICtrlCreateLabel("Download is 0% complete...", 10, 45, 280, 25)$SourceSize = FileGetSize($SrcPath & "\" & $FileName); Get size of source file$TypeCommand = 'type "' & $SrcPath & '\' & $FileName & '" > "' & $DestPath & '\' & $FileName & '"'Run(@ComSpec & ' /c ' & $TypeCommand, $DestPath, @SW_SHOW)GUISetState(@SW_SHOW, $ProgGUI)While (1) Sleep(1000) $DestSize = FileGetSize($DestPath & "\" & $FileName); Get size of destination file If $DestSize = $SourceSize Then GUIDelete($ProgGUI) MsgBox(32, "File progress", "Download complete.") ExitLoop Else $Progress = Int(($DestSize / $SourceSize) * 100) GUICtrlSetData($ProgBar, $Progress) GUICtrlSetData($ProgLabel, "Download is " & $Progress & "% complete...") EndIfWEndI had never noticed Microsoft's bizzare behavior on the copy creating the destination file as full size before it even has the data - but I consider them slime anyway... As compensation for having to put up with their sorry crap, I hereby grant you permission to download, distribute, and install as many copies of Linux as you want - for life! Weeeeeee!!!!!!!!!!! Well... as much as I appreciate the effort on this one, that won't do either. Take an actual RAR file and try the type command on it.. all that you get as your report is "Rar!" that's it... I can see where you're going with this though, and I have to say that it's a great idea... the only limiting factor of it is what I just wrote... Type'ing out a compressed RAR file only gives you that as the return... I think I'm screwed on this one...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now