Jump to content

New To Autoit3 Scripting, Would Like Help.


Recommended Posts

So I'm sorta new to this scripting business... I've already created a few cool scripts, but I'm stuck on this one.

I'm using FTP.au3 (thanks, w0uter!) and a modified version of Quicksilver's "Convert Image Size and Upload" script. I know I'm not doing the right thing, because the file is not uploaded. What I'm attempting to do is simply upload a file to my ftp server... Do I need any script other than ftp.au3 in order to do this? How do I do this!?

If you guys couldn't tell, I have no idea what I'm doing when it comes to FTPing files using AutoIT!

I've already entered all my server/username/password information in the areas I'm supposed to in the modified version of Quicksilver's script (the .ini file). Again, do I even need to do this?

Sorry if this is a stupid question. :)

If it's no trouble to any of you, could you explain to me how to FTP a file?

Thanks in advance!

Link to comment
Share on other sites

If it's no trouble to any of you, could you explain to me how to FTP a file?

I don't know what Quicksilver is, but if you could post your existing code and the contents of your ini file, I'm sure someone will offer help. Just be sure to mask your actual user name, password, and ftp server... :) Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

I don't know what Quicksilver is, but if you could post your existing code and the contents of your ini file, I'm sure someone will offer help. Just be sure to mask your actual user name, password, and ftp server... :)

and please make sure to remove login or server details before posting your code. anyone on here that would want to see it, definitely does not need to.
Link to comment
Share on other sites

Quicksilver's the guy who made that image resizer script.

It's probably horribly wrong, but that's why I'm coming to you guys. :(

This is the modified version.

#include <File.au3>
#include <FTP.au3>
#include <file.au3>

$filename   = StringLeft(@ScriptName,StringLen(@ScriptName)-4)
$ini_file   = $filename&".ini"
$file       = FileOpen($ini_file, 0)
$server     = FileReadLine($file,1)
$username   = FileReadLine($file,2)
$pass       = FileReadLine($file,3)
FileClose($file)

$dir        = @ScriptDir&"\Password\New"
$filenames  = @ScriptDir&"\Password\New\*.log"
$search     = FileFindFirstFile($filenames)


$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search 

pattern")
    Exit
EndIf

While 1
 $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $filenew = $file
    $filenew = StringLower(StringReplace($filenew," ", "_"))
    $Ftpp = _FtpPutFile($Conn, $dir & $file, '/' & $file)
WEnd

$Ftpc = _FTPClose($Open)
FileClose($search)

And here's the .ini file:

In dieser Datei werden die FTP Daten festgelegt.
*my FTP server*
*my username*
*my password*

And then I've got the stock FTP.au3 file.

Again, it's all probably horribly wrong. Do I even need these files, or do I just need ftp.au3?! :)

Thanks again, guys!

Edited by Valefox
Link to comment
Share on other sites

Quicksilver's the guy who made that image resizer script.

It's probably horribly wrong, but that's why I'm coming to you guys. :(

This is the modified version.

#include <File.au3>
#include <FTP.au3>
#include <file.au3>

$filename   = StringLeft(@ScriptName,StringLen(@ScriptName)-4)
$ini_file   = $filename&".ini"
$file       = FileOpen($ini_file, 0)
$server     = FileReadLine($file,1)
$username   = FileReadLine($file,2)
$pass       = FileReadLine($file,3)
FileClose($file)

$dir        = @ScriptDir&"\Password\New"
$filenames  = @ScriptDir&"\Password\New\*.log"
$search     = FileFindFirstFile($filenames)
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search 

pattern")
    Exit
EndIf

While 1
 $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $filenew = $file
    $filenew = StringLower(StringReplace($filenew," ", "_"))
    $Ftpp = _FtpPutFile($Conn, $dir & $file, '/' & $file)
WEnd

$Ftpc = _FTPClose($Open)
FileClose($search)

And here's the .ini file:

In dieser Datei werden die FTP Daten festgelegt.
*my FTP server*
*my username*
*my password*

And then I've got the stock FTP.au3 file.

Again, it's all probably horribly wrong. Do I even need these files, or do I just need ftp.au3?! :)

Thanks again, guys!

add msgbox()'s to check your values before trying to send them, that may help you identify an issue. make sure your server/password etc is all correct when it's tryign to connect
Link to comment
Share on other sites

add msgbox()'s to check your values before trying to send them, that may help you identify an issue. make sure your server/password etc is all correct when it's tryign to connect

I was thinking about doing that after reading some other posts around here... But I don't know how to do it. :) I would if I knew how!

Again, I'm a newbie to this kind of scripting... And in general, new to scripting.

Thanks for the all the help, especially cameronsdad... I'd appreciate it if you kept helping. :(

Link to comment
Share on other sites

I was thinking about doing that after reading some other posts around here... But I don't know how to do it. :) I would if I knew how!

Again, I'm a newbie to this kind of scripting... And in general, new to scripting.

Thanks for the all the help, especially cameronsdad... I'd appreciate it if you kept helping. :(

no worreis man. just paste then in after the section where the values are assigned:

msgbox(0,"Filename",$filename)
msgbox(0,"Ini file",$ini_file)
msgbox(0,"Server",$server)
msgbox(0,"username", $username)
msgbox(0,"pass",$pass)

then just make sure you're getting the right values into the right variables.

Link to comment
Share on other sites

no worreis man. just paste then in after the section where the values are assigned:

msgbox(0,"Filename",$filename)
msgbox(0,"Ini file",$ini_file)
msgbox(0,"Server",$server)
msgbox(0,"username", $username)
msgbox(0,"pass",$pass)

then just make sure you're getting the right values into the right variables.

OK, thanks a bunch for all the help.

Apparently, it's having trouble reading the INI file. It detects the INI file, but maybe the command to read it is wrong? Ehh, what do I know. I'm going to try to plug in the username/pass/server directly into the script... I'll edit this post with the results.

Edit: OK, cool. It now detects the three variables... But it still doesn't upload the file! Any more suggestions?

Ah, and another thing. Notice in the script how it does a quick search for the file... It doesn't return any error, so it seems as though everything's fine on my end... Or not? What do I know?!

Thanks again!

Edited by Valefox
Link to comment
Share on other sites

OK, thanks a bunch for all the help.

Apparently, it's having trouble reading the INI file. It detects the INI file, but maybe the command to read it is wrong? Ehh, what do I know. I'm going to try to plug in the username/pass/server directly into the script... I'll edit this post with the results.

Edit: OK, cool. It now detects the three variables... But it still doesn't upload the file! Any more suggestions?

Thanks again!

is it giving you an error or something? it's possible that your username/pass may be wrong...
Link to comment
Share on other sites

is it giving you an error or something? it's possible that your username/pass may be wrong...

Nope, no error. The script runs, but nothing happens at all, except the MsgBox'es that tell me that every piece of info is correct.

Is there any alternative to using a modified script? I still don't understand the purpose of FTP.au3 if you need another script in order to ftp a file!

Gaaah, thanks again!

Link to comment
Share on other sites

Nope, no error. The script runs, but nothing happens at all, except the MsgBox'es that tell me that every piece of info is correct.

Is there any alternative to using a modified script? I still don't understand the purpose of FTP.au3 if you need another script in order to ftp a file!

Gaaah, thanks again!

the ftp.au3 gives you the ability to use ftp functions which are not part of the standard functions in autoit. an similar situation is like: think of ftp.au3 as the instruction set to wash your car. by having that and knowing exactly how to wash your car makes it no more possible if you have no soap or water, or even a car for that matter. make sense?
Link to comment
Share on other sites

the ftp.au3 gives you the ability to use ftp functions which are not part of the standard functions in autoit. an similar situation is like: think of ftp.au3 as the instruction set to wash your car. by having that and knowing exactly how to wash your car makes it no more possible if you have no soap or water, or even a car for that matter. make sense?

Yes, now it does. I'm still hung up on trying to get this to work. Anything else you can think of? Heck, anyone else want to give this a go?

Link to comment
Share on other sites

sometimes it helps to take a deep breath, step back, and approach the problem from another perspective.

For example, the microsoft ftp client in xp is scriptable (see the /s) switch; if you know the commands you want to execute, you can put them in a flat file, and call it.

Second, scale back on the scope of what you are trying to accomplish initially. Build blocks of code that work, then put them together, rather than trying to <hit home run | score from 80 yards out|insert favorite sports analogy>

Also, there are exteremely robust ftp clients available, that provide a wide range of exitcodes and verbose descriptions to tell you what went wrong, and enabling much more sophisticated error handling... You might be better off writing a "wrapper" for one of these, (I like ncftpget and ncftpput -- available from www.ncftp.org).

Get the operations you need to work w/ code you understand, then you can work on trying to understand other people's code.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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...