About Intellectual Property IP Training IP Outreach IP for… IP and... IP in... Patent & Technology Information Trademark Information Industrial Design Information Geographical Indication Information Plant Variety Information (UPOV) IP Laws, Treaties & Judgements IP Resources IP Reports Patent Protection Trademark Protection Industrial Design Protection Geographical Indication Protection Plant Variety Protection (UPOV) IP Dispute Resolution IP Office Business Solutions Paying for IP Services Negotiation & Decision-Making Development Cooperation Innovation Support Public-Private Partnerships The Organization Working with WIPO Accountability Patents Trademarks Industrial Designs Geographical Indications Copyright Trade Secrets WIPO Academy Workshops & Seminars World IP Day WIPO Magazine Raising Awareness Case Studies & Success Stories IP News WIPO Awards Business Universities Indigenous Peoples Judiciaries Genetic Resources, Traditional Knowledge and Traditional Cultural Expressions Economics Gender Equality Global Health Climate Change Competition Policy Sustainable Development Goals Enforcement Frontier Technologies Mobile Applications Sports Tourism PATENTSCOPE Patent Analytics International Patent Classification ARDI – Research for Innovation ASPI – Specialized Patent Information Global Brand Database Madrid Monitor Article 6ter Express Database Nice Classification Vienna Classification Global Design Database International Designs Bulletin Hague Express Database Locarno Classification Lisbon Express Database Global Brand Database for GIs PLUTO Plant Variety Database GENIE Database WIPO-Administered Treaties WIPO Lex - IP Laws, Treaties & Judgments WIPO Standards IP Statistics WIPO Pearl (Terminology) WIPO Publications Country IP Profiles WIPO Knowledge Center WIPO Technology Trends Global Innovation Index World Intellectual Property Report PCT – The International Patent System ePCT Budapest – The International Microorganism Deposit System Madrid – The International Trademark System eMadrid Article 6ter (armorial bearings, flags, state emblems) Hague – The International Design System eHague Lisbon – The International System of Appellations of Origin and Geographical Indications eLisbon UPOV PRISMA Mediation Arbitration Expert Determination Domain Name Disputes Centralized Access to Search and Examination (CASE) Digital Access Service (DAS) WIPO Pay Current Account at WIPO WIPO Assemblies Standing Committees Calendar of Meetings WIPO Official Documents Development Agenda Technical Assistance IP Training Institutions COVID-19 Support National IP Strategies Policy & Legislative Advice Cooperation Hub Technology and Innovation Support Centers (TISC) Technology Transfer Inventor Assistance Program WIPO GREEN WIPO's Pat-INFORMED Accessible Books Consortium WIPO for Creators WIPO ALERT Member States Observers Director General Activities by Unit External Offices Job Vacancies Procurement Results & Budget Financial Reporting Oversight

Net::SFTP Hints from IP Offices

Whenever we receive a hint or tip from IP offices concerning any of the PCT EDI software or services, we publish it for the use of others.

A Simple Perl Script Using Net::SFTP

Description

This simple demo program was taken from the Net::SFTP documentation and modified slightly by Jim Fullton at WIPO. To use this example, you must first have set up a correct OpenSSH user installation as described in the Users Guide, with working public key authentication. As with the other examples, replace "xx" with your account name. This demonstration is based upon sample code provided with the Net::SFTP module, and will simply print a directory listing of the user account, and then exit. As outlined in the Net::SFTP documentation, the functions to 'Get' (sftp->Get()) a file from the server and 'Put' (sftp->Put()) a file on the server are almost identical to the 'ls' (sftp->ls()) request implemented by the example below.

How To.....


#!/usr/bin/perl -w

############################################################
#
# demo1.pl - demonstrate the basic concepts of using the 
# Net::SFTP Perl module with the WIPO PCT-EDI server.
#
# Makes a connection and returns a directory listing
# Requires a properly configured OpenSSH public key authentication
# environment for user "xx", where xx is the 2 letter WIPO ST.3
# country code.
#
# May 27, 2004  Jim Fullton.  A slight modification of one of
# the examples in the Net::SFTP documentation
#
# Arguments:  demo1.pl -v -u=username
# Both are optional.  If -u  username is not provided
# the current username for the account is used
#
# You must be using public key encryption for this example
# to work.  This is the first of many examples.
#
# ./demo1.pl pctftp.wipo.int -u xx
#
############################################################

use strict;

use Net::SFTP;
use Getopt::Long;

my %opts;
my $user;
Getopt::Long::Configure('no_ignore_case');
GetOptions(\%opts,  "v", 'u=s'=>\$user);

my($host) = @ARGV;
die "usage: demo1 [options] hostname" unless $host;

# set up the arguments based on the command line options
my %args = (ssh_args => []);
$args{debug} = 1 if $opts{v};
push @{ $args{ssh_args} }, user => $user ;

# make our connection

print "Connecting to $host...\n";

my $sftp = Net::SFTP->new($host, %args);

# get a listing of the base directory

$sftp->ls("." , sub { print $_[0]->{longname}, "\n" });

print "Finished\n";