I have the following commands configured in a script:
/system gps
monitor file=[/system identity get name]
The output of the above command creates a file with the GPS location using the syntax “hostname.txt”. It forces the .txt extension on this file even if I don’t specify it.
I then issue a command to upload the newly created file to an FTP location. The problem is that the filename will vary from system to system as it’s based on the hostname. Is there anyway to specify a variable in the “/tool fetch upload” command?
This does work, but I have to specify the exact filename:
/tool fetch upload=yes mode=ftp address=x.x.x.x src-path=“SourceFile.txt” dst-path=“SourceFile.txt”
I would like to work out the proper syntanx that would allow the file name to be based on the identity and add “.txt” to end of that variable:
So, for example something similar to this is what I need, but this syntax does NOT work with the “.txt” added on to the variable section [/system identity get name].
/tool fetch upload=yes mode=ftp address=x.x.x.x src-path=[/system identity get name].txt dst-path=[/system identity get name].txt
You could have used concatenate operation also:
/tool fetch upload=yes mode=ftp address=x.x.x.x src-path=([/system identity get name].“.txt”) dst-path=([/system identity get name].“.txt”)
No you do not need to use :global instead of :local, only if run from the console, since each statement is then treated as independent scope, unless it is part of a common block (i.e. in {})
I’m all for teaching good practice, the reason I commented in the first place. Putting multiple statement in on line separated with semikolon would sure work, but personally I am not a fan of multi statement lines, they are no easy read. All down to taste of course.