I’ve got a problem with dst-path argument in my script. I need to upload file to the specific directory on my server, and it’s not working as it supposed to. Here is source:
:log info "export beginning now"
:global exportfile ([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . "-" . [/system resource get board-name])
/export compact file=$exportfile
:log info "export pausing for 10s"
:delay 10s
:log info "export being transfered"
/tool fetch address=10.0.0.2 port=21 user=ftp password=ftppass mode=ftp upload=yes src-path="$exportfile" dst-path="upload/$exportfile"
:log info "export pausing for 10s"
:delay 10s
:log info "remove export"
/file rem $exportfile
:delay 5s
:log info "export finished"
Here is output of console after running it:
/system script run Export-ftp
status: failed
failure: cannot open file
Problem doesn’t apear if i do it directly without script as this:
Everything is ok with file name. There is a problem with complex path as argument of ‘dst-path=’. It seems that i cannot pass complex path via variable. If i use it from CLI without variables it works, but when i put variable to this option it returns:
status: failed
failure: cannot open file
which is connected with write permissions on ftp server. RoS tries to write the file in main directory, while it should write it one level deeper.
I’ve already tried pass whole path as one variable, as combined string, and just a second ago without variable, just with complex path and it also didn’t work. As for me the clue is in '' sign in that path, but for now i don’t know what to do with it.
Can u paste your sample here? I will check your solution soon, but now i don’t see what’s the difference of dividing one script into two others invoked by third one.
Well, I’ve checked it once again and i’ve found what was wrong. The only problem was with (yes, yes i know;) ) file name. Variable $exportfile was right, but this was the file name without extension ‘.rsc’. Correct file was created on ftp server but without .rsc extension, that’s how i’ve figured it out, and due to that it had 0 bytes size. So the proper line of the script should look like this: