Community discussions

MUM Europe 2020
 
fenek96
just joined
Topic Author
Posts: 11
Joined: Thu Nov 11, 2010 5:57 pm

Problem with Fetch dst-path

Thu May 05, 2016 7:33 pm

I combined several scripts to create the automatic creation of backup settings mikrotiks . The Basic version is working properly . However, I would like all sort of catalogs and here there is a problem with the transfer of the file to a specific folder. Any suggestions ?I combined several scripts to create the automatic creation of backup settings mikrotiks . The Basic version is working properly. However, I would like all sort of catalogs and here there is a problem with the transfer of the file to a specific folder. Any suggestions ?

Working code:
{
:local curDate [/system clock get date]
:local curTime [/system clock get time]
:local systemName [/system identity get name]
:local curMonth [:pick $curDate 0 3]
 :set curMonth ( [ :find key="$curMonth" in="jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec" from=-1 ] / 4 + 1)
 if ( $curMonth < 10 ) do={
  :set curMonth ( "0".$curMonth )
 } else={
  :set curMonth $curMonth
 }
:local curDay   [:pick $curDate 4 6]
:local curYear  [:pick $curDate 7 13]
:local curHour  [:pick $curTime 0 2]
:local curMin   [:pick $curTime 3 5]
:global routeros [ /system package get number=0 value-name=version ]
:global ipadress [/ip address get [find interface="loop"] address]
:for i from=( [:len $ipadress] - 1) to=0 do={:if ( [:pick $ipadress $i] = "/") do={:set $ipadress [:pick $ipadress 0 $i]}}
:global boardname [/system resource get board-name]
:global adresacja [("192.168.1.". [:pick $ipadress 11 14])]
:for i from=( [:len $boardname] - 1) to=0 do={:if ( [:pick $boardname $i] = " ") do={:set boardname [:pick $boardname 0 $i]}}
:global exportfilename ([/system identity get name] . "|||" . $adresacja . "|||" . $curYear ."-". $curMonth."-". $curDay ."_". $curHour .":". $curMin . "|||" .  $boardname . "|||" . $routeros )
:global cmd1 "export file=$exportfilename"
:global cmd3 "export verbose file=$exportfilename"
do {execute $cmd3}
/tool fetch address="192.168.1.2" port=21 user="mikrotik" password="mikrotik11" mode=ftp upload=yes src-path=("$exportfilename" . ".rsc") dst-path=("$exportfilename" . ".rsc")
/file remove "$exportfilename.rsc"
/system script environment remove [find name=ipadress]
/system script environment remove [find name=exportfilename]
/system script environment remove [find name=boardname]
/system script environment remove [find name=cmd1]
/system script environment remove [find name=cmd3]
}
Problem with dst-path:
:local curDate [/system clock get date]
:local curTime [/system clock get time]
:local systemName [/system identity get name]
:local curMonth [:pick $curDate 0 3]
 :set curMonth ( [ :find key="$curMonth" in="jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec" from=-1 ] / 4 + 1)
 if ( $curMonth < 10 ) do={
  :set curMonth ( "0".$curMonth )
 } else={
  :set curMonth $curMonth
 }
:local curDay   [:pick $curDate 4 6]
:local curYear  [:pick $curDate 7 13]
:local curHour  [:pick $curTime 0 2]
:local curMin   [:pick $curTime 3 5]
:global routeros [ /system package get number=0 value-name=version ]
:global ipadress [/ip address get [find interface="loop"] address]
:for i from=( [:len $ipadress] - 1) to=0 do={:if ( [:pick $ipadress $i] = "/") do={:set $ipadress [:pick $ipadress 0 $i]}}
:global boardname [/system resource get board-name]
:global adresacja [("192.168.1.". [:pick $ipadress 11 14])]
:for i from=( [:len $boardname] - 1) to=0 do={:if ( [:pick $boardname $i] = " ") do={:set boardname [:pick $boardname 0 $i]}}
:global exportfilename ([/system identity get name] . "|||" . $adresacja . "|||" . $curYear ."-". $curMonth."-". $curDay ."_". $curHour .":". $curMin . "|||" .  $boardname . "|||" . $routeros )
:global cmd1 "export file=$exportfilename"
:global cmd3 "export verbose file=$exportfilename"
do {execute $cmd3}
/tool fetch address="192.168.1.2" port=21 user="mikrotik" password="mikrotik11" mode=ftp upload=yes src-path=("$exportfilename" . ".rsc") dst-path=(/AP/address/"$exportfilename" . ".rsc")
/file remove "$exportfilename.rsc"
/system script environment remove [find name=ipadress]
/system script environment remove [find name=exportfilename]
/system script environment remove [find name=boardname]
/system script environment remove [find name=cmd1]
/system script environment remove [find name=cmd3]
}

Who is online

Users browsing this forum: No registered users and 12 guests