Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Do the Ftp Script Commands Work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Do the Ftp Script Commands Work?

    I'm trying to do some FTP stuff from within an XBasic Ajax callback function. In particular, I'm trying to download files from an FTP server and, after each download, delete the file. Now I have no problem using "ftp_get_file" to get each file; however, as there is no analogous high-level function to delete files, I've been driven towards trying to write a script (using the commands listed in the Help for "ftp_script_run" and "ftp_script_run_silent". Unfortunately, none of them seem to work (for me, at least).

    So I decided to narrow things down by just trying to download one file from the server (the file is located in the "/FromX" directory): Here's a segment of code I'm trying to use:

    Code:
    			DIM cmd AS C = <<%str%
    					connect|ftp.xxx.com 
    					onerror|error|Could not connect 
    					login|XXX|xx
    					onerror|error|Could not log in 
    					cd|/
    					cd|FromX	
    					get|p.sourcefile|p.destfile
    					onerror|error|could not get p.sourcefile
    			%str%
    			cmd = replace_variables_in_string(cmd,em,"p")
    			DIM result AS C = ftp_script_run_silent(cmd,.T.)
    I've double-checked that the string substitution is correct. Unfortunately, regardless, the files are never downloaded. As I say, if I use "ftp_get_file" then there's no problem. I understand that the help seems to imply that "ftp_script_run" and "ftp_script_run_silent" are for use with the "ftp_makecommandlist" function, but then why are we given the "low-level" commands themselves in the help topic.

    I've searched and have seen at least one post in which it is said that these kinds of scripts DO work, but I can't figure out how to do it.

    Any assistance would be appreciated.

    #2
    Re: Do the Ftp Script Commands Work?

    Do the FTP Script Commands Work? Yes they do.

    You didn't include your file info "p" variable so I don't know how you set that part up.

    CASE matters.
    You must include the source path and the target path for get and put.

    I'm not sure how the onerror stuff works... but this script works. The file I'm downloading is in a sub-folder named subfolder1

    Code:
    dim cmd as c
    cmd = <<%str%
    connect|ftp.yoursite.com
    onerror|error|Could not connect
    login|yourname|yourpw
    onerror|error|Could not log in
    get|/subfolder1/mynewfile.MPX|e:\myfolder\testfile.xxx
    onerror|error|could not get file
    cd|subfolder1
    rm|mynewfile.MPX
    %str%
    result = FTP_SCRIPT_RUN_SILENT(cmd, .T.)
    So... this script gets the file, changes directory to the folder that file is in, and then deletes the file. You needed to take a look at the ftp_get_file function and apply the same file format to the script get command.

    Comment


      #3
      Re: Do the Ftp Script Commands Work?

      Wow! I was expecting "the ftp script commands are no longer supported" or "the ftp script commands only work on the Desktop". Thanks for giving me some hope I can accomplish what I need to. I'm going to keep testing using a simpler and simpler script and a different FTP server, but I can't figure out for the life of me why I get absolutely no results.

      My client needs this solution yesterday (each day of delay costs $$$) so if I can't figure it out soon I'll need to go to my fallback plan of a C# desktop solution with Framework FTPserver commands that work flawlessly. I'd prefer to do it on the web, but sometimes you've got to just give up the chase. :)

      Thanks much Davidk for posting and trying to help me out.

      BTW: I tried to use the "FTP_MakeCommandList" (I think that's the name, I can't look it up right now) and it did absolutely nothing. That is I tried executing a line of code cmd = FTP_MakeCommandList(....) and then ?cmd (like in the help) and got cmd = "". Who knows?

      Comment


        #4
        Re: Do the Ftp Script Commands Work?

        Originally posted by Davidk View Post
        Do the FTP Script Commands Work? Yes they do.

        You didn't include your file info "p" variable so I don't know how you set that part up.

        CASE matters.
        You must include the source path and the target path for get and put.

        I'm not sure how the onerror stuff works... but this script works. The file I'm downloading is in a sub-folder named subfolder1

        Code:
        dim cmd as c
        cmd = <<%str%
        connect|ftp.yoursite.com
        onerror|error|Could not connect
        login|yourname|yourpw
        onerror|error|Could not log in
        get|/subfolder1/mynewfile.MPX|e:\myfolder\testfile.xxx
        onerror|error|could not get file
        cd|subfolder1
        rm|mynewfile.MPX
        %str%
        result = FTP_SCRIPT_RUN_SILENT(cmd, .T.)
        So... this script gets the file, changes directory to the folder that file is in, and then deletes the file. You needed to take a look at the ftp_get_file function and apply the same file format to the script get command.
        Well, at least I've got it working from the Interactive Window. From an Ajax Callback, not.

        Eureka: The problem seems to be the <<%str% %str%. If I write cmd as a quoted string with crlf() then it works. Who knows? I'll take it. Thanks again, David, for confirming these commands work.
        Last edited by nlk10010; 12-09-2015, 11:04 AM. Reason: New Information

        Comment


          #5
          Re: Do the Ftp Script Commands Work?

          For a more robust FTP upload you can use the new CURL feature. This allows for FTP using passive mode which is much more compatible behind firewalls.
          Code:
                  servername="URLofFTPServer"
                  remotedir="/remotesubdirectory"
                  username="YourFTPUsername"
                  password="Your FTPPassword"
                  apppath=a5.Get_Path()+chr(92)
          	fullname=apppath+fname
                  result=FTP_Upload_Curl(fullname,"",servername,remotedir,Username,Password)
          	fl2 = result = "OK"
          	if fl2
          		status = status + "Uploaded file successfully"+crlf()
          	else
          		status = status + "File failed to upload."+crlf()
          	end if
          This code assumes the file you intend to send via FTP is in the webroot folder.
          Brad Weaver, President
          ComputerAid International
          Ottawa ON Canada
          Versailles KY USA
          www.compuaid.com

          Comment


            #6
            Re: Do the Ftp Script Commands Work?

            Well, right now I don't need to do any uploads (though I will later). I will treat your post as documentation for FTP_Upload_Curl (just in case Alpha doesn't document it for awhile).

            Thanks much.

            Comment


              #7
              Re: Do the Ftp Script Commands Work?

              Originally posted by nlk10010 View Post
              Well, at least I've got it working from the Interactive Window. From an Ajax Callback, not.

              Eureka: The problem seems to be the <<%str% %str%. If I write cmd as a quoted string with crlf() then it works. Who knows? I'll take it. Thanks again, David, for confirming these commands work.
              I ran this as an ajax callback using both %str% and %txt%... both work with the code I posted. What version of Alpha are you using?

              Further, regarding FTP_MakeCommandList... this isn't something you want to use anyway. This is specifically to create FTP commands to upload a folder of files from local to server. You want to download and delete. This from the doc...

              Code:
              The FTP_MakeCommandList() function is a helper function for use with FTP_SCRIPT_RUN()to construct a FTP script to transfer all of the files in a folder (including all sub-folders). The script will generate the necessary commands to re-create the folder structure of the source folder on the FTP client.
              If you give FTP_MakeCommandList() a valid local folder... e.g.

              Code:
              cmd = FTP_MakeCommandList("e:\internet\IOSBurner","ftp.myaddress.com","myname","mypassword")
              This is a valid folder on my system... and so cmd contains...

              Code:
              connect|ftp.myaddress.com
              onerror|error|Could not connect
              login|myname|mypassword
              onerror|error|Could not log in
              binary
              put|e:\internet\IOSBurner\FreeISOBurner.exe|FreeISOBurner.exe

              Comment


                #8
                Re: Do the Ftp Script Commands Work?

                Davidk:

                I'm using the latest AA (at least that's what it tells me each time I "Check for Updates").

                I understand what the docs say FTP_MakeCommandList is used for. However, before I posted here, I thought I would try to view the code it generated to see if the actual syntax differed from that specified in the Help file (this is something that is actually suggested by Alpha). I\I thought it might give me clues how to write my own script. I just thought it was odd that it didn't generate ANY code.

                I kept "copying and pasting" the <<%str% %str% block, so maybe the line lengths were too great or there were some invisible characters caught in the text. I don't know. Perhaps the reason is "unknowable". :)

                Thanks.

                Comment


                  #9
                  Re: Do the Ftp Script Commands Work?

                  I believe it didn't generate code because your source details were not right or did not exist. I found the same. Case didn't seem to matter for the source, but the drive and folder have to exist. When all was good, script code was generated.

                  Comment


                    #10
                    Re: Do the Ftp Script Commands Work?

                    OK, that makes sense (you correctly inferred I was using dummy arguments). At least that mystery is cleared up. The other one (i.e. the problem I'm having with using <<%str%......%str% tags) is still "haunting" me, however.

                    Regardless, it's good to be able to get on with things.

                    Comment


                      #11
                      Re: Do the Ftp Script Commands Work?

                      Both <<%str% and <<%txt% work. Just make sure you don't have any extra spaces or tabs in the cmd script. Make sure you've not indented the <<%str% string.

                      This works...

                      Code:
                      dim cmd as c
                      cmd = <<%str%
                      connect|ftp.yoursite.com
                      onerror|error|Could not connect
                      login|username|userpw
                      onerror|error|Could not log in
                      get|/subfolder1/mynewfile.MPX|e:\subfolder1\testfile.xxx
                      onerror|error|could not get file
                      cd|subfolder1
                      rm|mynewfile.MPX
                      %str%
                      dim result as c
                      dim title as c = "FTP Test"
                      result = FTP_SCRIPT_RUN_SILENT(cmd, .T.)
                      This doesn't... with the cmd script indented. It adds an extra character to the cmd script that messes up processing.

                      Code:
                      function testFTP as c (e as p)
                      	
                      	dim cmd as c
                      	cmd = <<%str%
                      	connect|ftp.adjustablesoftware.com
                      	onerror|error|Could not connect
                      	login|katdav|davidkAEK1
                      	onerror|error|Could not log in
                      	get|/subfolder1/mynewfile.MPX|e:\digitaladjuster\testfile.xxx
                      	onerror|error|could not get file
                      	cd|subfolder1
                      	rm|mynewfile.MPX
                      	%str%
                      	dim result as c
                      	dim title as c = "FTP Test"
                      	result = FTP_SCRIPT_RUN_SILENT(cmd, .T.)
                      	
                      end function

                      Comment


                        #12
                        Re: Do the Ftp Script Commands Work?

                        NOW you tell me. How did you figure that one out?

                        Regardless, that's it then, I never had trouble with <<%str%...%str% before when I indented/prettyfied, but I'll avoid it like the plague in my FTP command scripts.

                        Thanks much.

                        Comment


                          #13
                          Re: Do the Ftp Script Commands Work?

                          It really depends on what you're doing with the string. Most XBasic functions don't care. You can indent, but then you'd have to clean up your string before processing it. I've seen it once or twice before so went back and had a look at your original post which has indented string... then tested the theory.

                          Comment

                          Working...
                          X