hi thanos I'm interested in replicating this. Could $host be a remote website with which I currently use sftp?
#!/usr/bin/perl -w use 5.011; use Net::SFTP::Foreign; my $upload_file = shift; my %vars = ( server_dir => 'perlmonks/scripts/', image_dir => 'pmimage', ); my $rvars = \%vars; say Dumper $rvars; my $sftp = get_tiny(); my $server_dir = $vars{"server_dir"}; $sftp->mkdir("/$server_dir") or warn "mkdir1 failed $!\n"; $sftp->setcwd("/$server_dir") or warn "setcwd1 failed $!\n"; $sftp->put($upload_file) or warn "upload put failed $!\n"; $sftp->ls($server_dir) or warn "can't ls $!\n"; say "return is $sftp"; undef $sftp; sub get_tiny { use 5.011; use warnings; use Net::SFTP::Foreign; use Config::Tiny; use Data::Dumper; my $ini_path = qw( /home/bob/Documents/html_template_data/3.values.i +ni ); say "ini path is $ini_path"; my $sub_hash = "my_sftp"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); say Dumper $Config; # -> is optional between brackets my $domain = $Config->{$sub_hash}{'domain'}; my $username = $Config->{$sub_hash}{'username'}; my $password = $Config->{$sub_hash}{'password'}; my $port = $Config->{$sub_hash}{'port'}; #dial up the server say "values are $domain $username $password $port"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password ) or die "Can't connect: $!\n"; return $sftp; } __END__
This is what I've been using to try to start up a conversation with a remote server and it's either not the right thing or I don't know how to script it. I looked at your repo. Can you say a few words as to what a Snippet is? Thanks,
In reply to Re^2: Sample REST request & response code
by Aldebaran
in thread Sample REST request & response code
by kanewilliam7777
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |