How to use OW3 to scp or ftp a file to a remote server

Michael Houlberg michael at houlbergdevelopment.com
Wed Jun 15 18:54:18 UTC 2022


Terry,

I’ve been able to use OW3 FTP working to do SFTP with Omnis 10.2, so it can be done.

From the Omnis Docs:

Secure FTP (SFTP)
The FTP Worker Object supports Secure FTP (SFTP). There are some differences in functionality when using SFTP:
	▪	You use URLs of the form SFTP:// to request an SFTP connection.
	▪	You must explicitly select a server character set - kUniTypeAuto will cause the worker to return an error.
	▪	The append file action is not supported.
	▪	If you have written code that uses the execute action, be aware that SFTP servers support different commands to FTP servers.
	▪	The remaining actions work as expected.
In addition, there are some properties and methods, primarily related to how a connection is authenticated. SFTP does not use TLS, so the secure options related to that only affect FTPS and FTP connections to be upgraded to TLS.

Excerpted from my code that sends a file using SFTP:

Do oFTP.$setCallingInst($cinst) ## sets up the callback for $completed

Calculate lHost as fPrefs.GardSFTPHost
If len(lHost)&fPrefs.GardSFTPPort>0
     Calculate lHost as con(lHost,':',fPrefs.GardSFTPPort)
End If
Calculate lUser as fPrefs.GardSFTPUser
Calculate lPassword as fPrefs.GardSFTPPassword
 
ReadBinFile (pNewName,lBinFile) Returns lBytesRead

If lBytesRead
     # send availability list to the property website
     Calculate oFTP.$timeout as 20
     Calculate oFTP.$callprogress as kFalse
     Calculate oFTP.$servercharset as kUniTypeUTF8 ## SFTP needs a specific servercharset, can't be kUniTypeAuto
     Calculate oFTP.$sshknownhostsfile as '' ## otherwise only known hosts can be connected to
     Calculate oFTP.$keepconnectionopen as kFalse ## once finished, it closes the connection automatically
     Calculate oFTP.$requiresecureconnection as kTrue ## we're doing SFTP, right?

     Do oFTP.$init(lHost,lUser,lPassword,kOW3ftpActionPutFile,lServerPath,lBinFile) Returns lSuccess
     If not(lSuccess)
          OK message SFTP Init error [oFTP.$errorcode]: [oFTP.$errortext]
          Quit method kFalse
     End If
     Do oFTP.$run() Returns lSuccess
     If not(lSuccess)
          OK message SFTP Run error [oFTP.$errorcode]: [oFTP.$errortext]
          Quit method kFalse
     End If
End If

Quit method kTrue

Good Luck!
Michael Houlberg
Houlberg Development, LLC


> On Jun 15, 2022, at 9:48 AM, Terence Young <terry.young at journeymhc.org> wrote:
> 
> Hi Doug,
> 
> I looked at the ftp OW3. I could not see where it would allow for sftp. It does allow for ftps, which is not the same thing as sftp.
> 
> Our server pes not allow ftp or ftps connections. It does allow for any of the ssh variants: ssh, scp, and sftp.
> 
> I was able to use applescript to run a terminal script that uses scp to transfer the file. The only problem I had was discovering how to escape spaces in the pathname.
> 
> The solution was to use double backspaces in the script; ordinarily, I would only have to use single backspaces.
> 
> Thank you very much for your help.
> 
> terry
> 
> 
> Terence J. Young, DC
> 
> System Administra
> 
> IT
> 
> (608) 280-2679
> 
> ________________________________
> From: Doug Easterbrook <doug at artsman.com>
> Sent: Tuesday, June 14, 2022 5:43 PM
> To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
> Cc: Terence Young <terry.young at journeymhc.org>
> Subject: Re: How to use OW3 to scp or ftp a file to a remote server
> 
> 
> CAUTION: This email originated from outside Journey. Please verify the sender before opening attachments or clicking links.
> 
> 
> there is an example in the ‘Samples’ in the HUB in your omnis developer copy called ‘FTP OW3 Worker Object’
> 
> It looks to have a lot of fill in the blanks to let you ftp/sftp from one location to another. I don’t know about SCP specifically. I do know that omnis accomplishes all of it using CURL.
> 
> 
> 
> anyway, I’ve used the HTTP OW3 Worker Object example to trace though and take working code from it to add support to background downloads for our update installers. it downloads a complete runtime installer for Theatre Manager into a client directory …. its very nice.
> 
> it goes along with the shell script I sent you moments ago. we download the zip and then use ditto to expand it, then run it via launch program
> 
> I know thats not what you asked .. but its is a great example how the HTTP worker can get updates onto a local machine from a server and run them.
> 
> 
> in your case, the FTP worker should be able to move files from you to an FTP server
> 
> 
> 
> 
> 
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug at artsman.com
> http://www.artsman.com
> Phone (403) 650-1978
> 
> On Jun 14, 2022, at 10:21 AM, Terence Young <terry.young at journeymhc.org<mailto:terry.young at journeymhc.org>> wrote:
> 
> Hi,
> 
> Does anyone know how to use OW3 to scp or sftp a file to another server from within Omnis. sample code appreciated.
> 
> terry
> 
> 
> Terence J. Young, DC
> 
> System Administrator
> 
> IT
> 
> (608) 280-2679
> 
> If you received this e-mail in error, please notify the sender, delete the e-mail, and do not use, disclose or store the information it contains. This e-mail and any attachments may contain confidential information, including records protected by WI Mental Health 51.30 and/or AODA federal confidentiality rules (42 CFR Part 2) - both prohibit you from making any further disclosure of this information unless further disclosure is expressly permitted by the written consent of the person to whom it pertains or as otherwise permitted by 51.30 or 42 CFR Part 2. A general authorization for the release of medical or other information is NOT sufficient for this purpose. Federal rules restrict any use of this information to criminally investigate or prosecute any alcohol or drug abuse client.
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list