Hi,
I tried to add a new variable $connection to open a connection.
It still doesn't work, but I think I'm very far from the truth....
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
match / {
<op-script-results> {
var $rpc = <get-software-information>;
var $result = jcs:invoke($rpc);
var $filename = "/config/juniper.conf.gz";
var $con = jcs: open();
var $ftpurl = "/var/tmp/juni.gz";
var $fileput = {
<file-put> {
<filename>$filename;
<encoding>"ascii";
<permission>'777';
<delete-if-exist>;
<file-contents>$result;
}
}
var $out = jcs:execute($con, $fileput);
expr jcs:close($con);
var $local-out = jcs:invoke($fileput);
<output> "Saving file on local host\n" _ $local-out;
var $year = substring( $localtime-iso, 1, 4 );
var $mounth = substring( $localtime-iso, 6, 2 );
var $day = substring( $localtime-iso, 9, 2 );
var $ora = substring( $localtime-iso, 12, 2 );
var $minut = substring( $localtime-iso, 15, 2 );
var $second = substring( $localtime-iso, 18, 2 );
var $dcguser = {
<username> "dcguser";
<port> "22";
}
var $connection = jcs: open("10.0.0.1", $dcguser);
var $file-copy-rpc=<file-copy>{
<source>"/config/juniper.conf.gz";
<destination>"scp://dcguser@10.0.0.1/dcguser/BCK/" _ $user _ "_" _ $year _ $mounth _ $day _ "_" _ $ora _ $minut _ $second _"_juniper.conf.gz";
}
var $results=jcs:invoke($file-copy-rpc);
<output> "Saving file on remote host\n" _ $results;
expr jcs:close($con);
}
}
************************************************************************************
Now the result is:
root@Router> op test
dcguser@10.0.0.1's password:
error: error opening connection (reading credentials)
error: Error in creating the session with "10.0.0.1" server
error: Session for server "" does not exist
Saving file on local host
/config/juniper.conf.gz
Saving file on remote host
Permission denied, please try again.
If I try to connect directly with same credential from router (OS or SHELL) via ssh or tftp to server all it's ok.
Is having all this in an automatism that I can't make it work.