[EMAIL PROTECTED] schrieb:
Hi.
I'm trying to add the ability to upload the current file via ftp using the
tools-menu, but failed doing it with the windows ftp.exe only.
So I thought lua might be up to the task, but I'm not good enough to make it
happen.
Here is what I'm trying to do:
My HTML/PHP-files may be located in
d:\web\domain1.tld\
d:\web\domain2.tld\
d:\web\domain3.tld\
...
each domain is on a different server and thus needs different login-parameters
(domain,login,password).
These details would be saved in simple textfiles. I might have
$(SciteDefaultHome)\profiles\domain1.tld.ftp
$(SciteDefaultHome)\profiles\domain2.tld.ftp
$(SciteDefaultHome)\profiles\domain3.tld.ftp
...
Each *.ftp contais the parameters for that server.
Now, when I trigger the script from Scite's menu, it should read the current
files parent directory name (e.g. "domain1.tld/"), load the apropriate profile
(in this case "$(SciteDefaultHome)\profiles\domain1.tld.ftp") and use the
windows ftp.exe with this information to upload the current file without user
interaction.
Please, can anybody help me with this? I didn't find and lua-ftp-scripts.
It works partially without lua, but then I can't get just the parent directory
name, only the whole $(FileDir).
Any help would be appreciated!
Gerrit
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest
With Lua I had no luck so I do it with perl.
script:
#!/usr/bin/perl -w
use Data::Dumper;
use Fcntl;
use strict;
our(
$host, $user, $password,
$fileName, $remoteDocRoot, $server, $serverData, $serverOptions,
$destPath, $localPath, $dataFile, $sftp, $remotePath
);
$| = 1;
$localPath = $ARGV[0];
my @parts = split(/\//, $localPath);
$fileName = pop(@parts);
$destPath = '';
$_ = $server = pop(@parts);
while(! /\./ ) {
$destPath = $_.'/'.$destPath;
$_ = $server = pop(@parts);
}
$server = $_;
printf("localPath:$localPath destPath:$destPath server:$server\n");
printf("server:$server\n");
$dataFile = "/srv/www/projects/$server";
if( -f $dataFile){
open(FH, '<', $dataFile);
while( <FH>){
chomp();
my @pair = split(':');
$serverOptions->{$pair[0]} = $pair[1];
}
printf ("user:%s remote:%s\n",$serverOptions->{user},
$serverOptions->{remote} );
if($serverOptions->{remote} eq '/'){
$remotePath = $destPath.$fileName ;
}
else{
$remotePath = $serverOptions->{remote}.'/'.$destPath.$fileName;
}
printf ("remotePath:%s\n",$remotePath );
}
if($serverOptions->{proto} eq 'sftp'){
use Net::SSH2;
my $ssh2 = Net::SSH2->new;
die "can't connect" unless $ssh2->connect($server);
die "can't authenticate"
unless $ssh2->auth_keyboard($serverOptions->{user},
$serverOptions->{pass});
my $res = $ssh2->scp_put ( $localPath , $remotePath) or die "$!";
printf "done upload %s %s\n",$res , $remotePath;
}
else{
if($serverOptions->{proto} eq 'ftp'){
use Net::FTP;
use File::Basename;
my $ftp = Net::FTP->new($server, Debug =>0, Passive =>1, Timeout
=> 10)
or die "Cannot connect to $server: $@";
printf("Connected %s\n", $server);
$ftp->login($serverOptions->{user}, $serverOptions->{pass})
or die "Cannot login ", $ftp->message;
printf("Logged in :-)\n");
$ftp->binary;
printf "start upload of %s to $remotePath%s\n", $localPath,
$ftp->pwd;
$ftp->put( $localPath , $remotePath) or die "$!";
printf "done upload to %s %s\n",
$ftp->size($remotePath) , $remotePath;
}
}
user options:
postUpdateProg=/srv/www/htdocs/teamtrier.de/safe/updateSftp
command.name.5.*=PostUpdate
command.5.*=$(postUpdateProg) "$(FilePath)"
command.subsystem.5.*=0
command.mode.5.*=savebefore:1
command.shortcut.5.*=Shift+Ctrl+PageUp
Cordially,
Axel
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest