Copy File to Remove Server

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Copy File to Remove Server

Post by jussij »

1. Download the pscp.exe found here: https://www.chiark.greenend.org.uk/~sgt ... atest.html

Place that executable in this folder:

Code: Select all

C:\Users\<Your User Id>\AppData\Local\Programs\Zeus\zGNU
From inside Zeus use the Tools, DOS Command Line menu to run this command:

Code: Select all

pscp  -h
That command should produce this output:

Code: Select all

PuTTY Secure Copy client
Release 0.74
Usage: pscp [options] [user@]host:source target
       pscp [options] source [source...] [user@]host:target
       pscp [options] -ls [user@]host:filespec
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -p        preserve file attributes
  -q        quiet, don't show statistics
  -r        copy directories recursively
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -P port   connect to specified port
  -l user   connect with specified username
  -pw passw login with specified password
  -1 -2     force use of particular SSH protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for user authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -hostkey aa:bb:cc:...
            manually specify a host key (may be repeated)
  -batch    disable all interactive prompts
  -no-sanitise-stderr  don't strip control chars from standard error
  -proxycmd command
            use 'command' as local proxy
  -unsafe   allow server-side wildcards (DANGEROUS)
  -sftp     force use of SFTP protocol
  -scp      force use of SCP protocol
  -sshlog file
  -sshrawlog file
            log protocol details to a file
2. This utility can be used to save a file to a remote server using the following command line:

Code: Select all

pscp  file_name user@host:/path/to/whereyouwant/thefile
The following Zeus macro can be be used to save the current file to the remote server.

Code: Select all

--
--        Name: Save File to Remote Host
--
--    Language: Lua Macro
--
-- Description: This macro will uses the pscp.exe tool to copy the current file to a remote host.
--
--              Refer to the sections marked with NOTE: as these will need to be configured to suit.
--
--              The macro can be run direction on an active file using the Macros menu or it can also be bound
--              to a keyboard key combination an run using those keys.
--
--              Finally the macro can be defined as a trigger which means it will run any time a file is saved.
--
--              To configure this macro for all document types, use the Options, Default Document Type menu and
--              attach the macro to the "File Save Prefix" trigger option. (e.g.)
--
--                 Options|Default Document Type...|Triggers|File Save Prefix = $zud\zScript\pscp_exec.lua
--
--              With this setting in place the macro will be run for all documents with all file extensions.
--
--              To configure this macro, for a particular document type, use the Options, Trigger Options menu
--              and attach the macro to the "File Save Prefix" trigger option. (e.g.)
--
--                 Options|Trigger Options...|File Save Prefix = $zud\zScript\pscp_exec.lua
--
--              With this setting in place the macro will only run for file extensions defined in the General
--              section of the document type.
--

local utils = require "utils"

function key_macro()
   -- macro only works for read/write documents.
   if (is_read_only() == 1) or (is_document() == 0) then
        -- only complain if this is not a trigger
        if is_trigger() == 0 then
            message("This macro can only be used with a writable document.")
            beep()
        end
     return
   end

   -- NOTE: The user id and password for user athentication. Note that
   --       it's not a good idea to include the password in the script
   --       file. A much better option would be to use private/public
   --       keys for the authentication.
   local userid   = "userid"
   local password = "password"

   -- NOTE: The host address and target folder
   local host = "127.0.0.1"
   local target_folder = "/test/"

   local arguments = ""

   -- NOTE: These options can be used to increase or decrease the debug output.
   --       arguments = arguments .. "-v" .. " "  -- increases the output
   arguments = arguments .. "-q -batch" .. " "    -- reduces the output

   -- NOTE: The are the other pscp.exe command line  options
   arguments = arguments .. "-scp -p" .. " "
   arguments = arguments .. "-pw " .. password .. " "
   arguments = arguments .. macro_tag("$F") .. " "
   arguments = arguments .. userid .. "@".. host .. ":"
   arguments = arguments .. target_folder;

   -- NOTE: Use debug flag to help debug the command line
   -- utils.DEBUG = 1

   local executable = "pscp.exe";
   local filename   = ""  -- NOTE: The filename is passed in as an argument above
   local directory  = macro_tag("$FDD")

   -- NOTE: The pscp.exe is run using a compiler output window which
   --       means it will only display an output window only if some
   --       output is produced.
   utils.run_compiler(executable, filename, directory, arguments, 2)
end

key_macro() -- run the macro
This macro can be bound to a keyboard key, the macros menu or used as a post file save trigger so the file is pushed to the server each time the file is saved.
Post Reply