11-10-2007 06:00 AM
Solved! Go to Solution.
06-26-2008 04:36 PM
It's very simple. You just need to file-copy command and source/destnation url:
Here's an op script:
jnpr@RE0# show system
scripts {
op {
traceoptions {
file filename;
flag all;
}
file wrn.xsl;
}
}
[edit]
jnpr@# run op wrn
On my server:
> ls *router*
router-config.gz
>
<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:junos="http://xml.juniper.net/junos/*/junos"
xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm"
xmlns:jcs="http://xml.juniper.net/junos/commit-scr
<xsl:import href="../import/junos.xsl"/>
<xsl:template match="/">
<op-script-results>
<xsl:variable name="rpc">
<file-copy>
<source>/config/juniper.conf.gz</source>
<destination>ftp://username
assword@x.x.x.x/router-config.gz</destination>
</file-copy>
</xsl:variable>
<xsl:variable name="result" select="jcs:invoke($rpc)"/>
</op-script-results>
</xsl:template >
</xsl:stylesheet>
07-21-2008 05:21 AM
Arborist,
thanks! Thats what I need!
Is it possible to add in this script some informational output like this:
ftp://username
assword@x.x.x.x/router-config.gz 100% of 44 kB 2318 kBps
---
Yev.
07-30-2008 12:04 AM
Arborist,
pelase answer to me.
I need this extra output for understanding is my ftp transfer good or bad.
Thanks in advance!
09-04-2008 01:38 PM
Sorry for the delay.
There is extra output for failure, but not for success. So you'll have to put in a conditional statement. The choose command will test if there is any contents (reply message) from the executed vairable "result".
<xsl:template match="/">
<op-script-results>
<xsl:variable name="rpc">
<file-copy>
<source>/config/juniper.conf.gz</source>
<destination>ftp://username
assword@x.x.x.x/router-config.gz</destination>
</file-copy>
</xsl:variable>
<xsl:variable name="result" select="jcs:invoke($rpc)"/>
<output>
<xsl:choose>
<xsl:when test="$result/message">
<xsl:value-of select="$result/message"/>
</xsl:when>
<xsl
therwise>FTP'd Successfully</xsl
therwise>
</xsl:choose>
</output>
</op-script-results>
</xsl:template >
A true condition will reply with a message, in this case any ftp failures.
Here I put in an incorrect login.
jnpr@router# run op wrn
fetch: ftp://username:*@x.x.x.x/router-config.gz: Not logged in
Here I disconnected interface from the network
jnpr@router# run op wrn
fetch: ftp://username:*@x.x.x.x/router-config.gz: No route to host
A false condition means there is no content reply from the executed variable. Which means FTP succeeded. Therefore I created test to reflect that:
jnpr@router# run op wrn
FTP'd Successfully