When I run the following command from Mikrotik SSH, I see an asterisk followed by a hex value, which will look something like like *4e.
:put [:execute { :ping localhost count=10 }]
According to the Mikrotik wiki, the :execute command executes commands in the background as a script job. When I print out the currently running jobs, I don't see any relation between the output above with the output of this.
[admin#MikroTik] > /system script job print
# SCRIPT OWNER STARTED
0 admin jun/05/2017 16:58:09
1 admin jun/05/2017 17:07:31
So, what does the output represent and how can I use it?
The return that you get is a MikroTik RouterOS Internal ID. In this case, this is an internal ID for the running job. Internal IDs are immutable references to the object which they represent and have the advantage of being the same between command executions even if concurrent operations are taking place which would change the objects # as shown by print.
You can identify an internal ID by the * followed by a hexadecimal number. In some cases, where there are multiple items to return as is common with find, you will get a ; delimited list of IDs such as:
*d;*1;*18;*3;*19;*1a;*20
Internal IDs can be used as when running other commands just like the printable number and is distinguished by the preceding *. Where a list of multiple internal ids is given, the command will run on each item.
Information on the internal ID data type can be found in the Scripting Manual. Internal IDs do not follow any ordering and you should not assume that they do. To get the internal ID of an object from its ID show in a print output, you can use :put [get <id>] where <id> is the printable id - the output will show the internal id as the .id property.
Related
On Ansible you can use register: some_var in order to save information about executed task but it seems that somehow I am not able to find the list of attributes documented anywhere.
I know about some of them, but I do want a full list as I is really annoying not to have documentation.
changed – set to boolean true if something happened (useful to tell when a task has done something on a remote machine).
stderr – contains stringy output from stderr
stdout – contains stringy output from stdout
stdout_lines – contains a list of lines (i.e. stdout split on \n).
Example, how do I know if the previous task failed?
There is no comprehensive list as each module returns its own list of variables.
There are common return values, which describe what a module (should) return as a minimum.
Some modules such as shell, are kind enough to list out the return values they provide in the docs.
I agree it would be quite nice to have a comprehensive cheatsheet listing the modules and return values. As it is, we're stuck with trolling through the python code for each module.
As an example, in the case of shell (which uses command under the covers), the return values are:
module.exit_json(
cmd = args,
stdout = out.rstrip("\r\n"),
stderr = err.rstrip("\r\n"),
rc = rc,
start = str(startd),
end = str(endd),
delta = str(delta),
changed = True,
warnings = warnings
)
I can't find an official list of the attribute of a register variable either. But I noticed a fact.
Refer to the explanation of register variable in chapter Loop. Do you notice what I noticed?
Do you see the "results" part in the Json output in this page? Each key that is present in the "results" part should be the whole attributes of a register variable.
And actually you can show the list of attributes of a register variable by yourself.
See the registered variable section in chapter Variable. There is a statement saying: Use of -v when executing playbooks will show possible values for the results.
Refer below url for register module:
http://docs.ansible.com/ansible/playbooks_variables.html#registered-variables
Also if a any task fails, it will fail the whole ansible playbook and exit. to ignore that and continue we need to use below step under that task
ignore_errors: True
To debug the playbook we are executing, we should pass "-v" to debug.
Using TeamCity 9.1.4.
I'm trying to get some server hostnames into a Command Line script with Configuration Parameters. I want each option to contain multiple hostnames.
My configuration:
vanmain => rad-ecr1,rad-ecr2,rad-ecr3,rad-myecr,rad-balancer
tor => rad2-bal,rad2-ecr1,rad2-ecr2,rad2-myecr
fvcdc => rad-fvcdc,rad-balancer
bccfa => rad-bccfa
When I select fvcdc in a build, I receive the following error message:
One of entered values 'rad-fvcdc' is not one of valid select item values: rad-ecr1,rad-ecr2,rad-ecr3,rad-myecr,rad-balancer,rad2-bal,rad2-ecr1,rad2-ecr2,rad2-myecr,rad-fvcdc,rad-balancer,rad-bccfa
How do I get the values into my script?
Dunkan,
I successfully reproduced your issue and was able to find out the root cause of it.
On my virtual installation I created a build with select type parameter, let's name it HostValue. Next, in Items field I copy/pasted values from your initial post and tried to reproduce the problem -- but executing the build was successful. Then I decided to reconfigure parameter and toggled Allow multiple checkbox, and viola, same error message as you got!
If you read small text below Value separator field, you will see, that default value is comma: , and as your values contain this symbol you got an error.
So, to solve this problem I can suggest you these variants:
If you don't need multiple choices, you can just turn off this feature and everything should work.
Replace default Value separator with custom one, for example <SEP>. Then whenever you will select multiple values for this parameter you will get something like:
"rad-ecr1,rad-ecr2,rad-ecr3,rad-myecr,rad-balancer"<SEP>"rad2-bal,rad2-ecr1,rad2-ecr2,rad2-myecr"<SEP>"rad-fvcdc,rad-balancer"
Replace comma in your values with some other separator, for example | or :. In this case it would look like:
"rad-ecr1:rad-ecr2:rad-ecr3:rad-myecr:rad-balancer","rad-fvcdc:rad-balancer"
After that you can use the value of this parameter as usual %HostValue% and parse depending on which variant you choose.
Maybe the error message from server could be a little bit clearer. Hope it will help you.
Also I would like to recommend you my plugin teamcity-web-parameters. It will allow you to create dynamic select values from external web service.
Take a look at this thread: https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206843785-How-to-specify-empty-value-for-Typed-Parameter -- looks very similar to your question.
I have a source file that contains two fields: IP_ADDRESS and USER_NAME. I want to check whether the IP address is correct or not before loading it to the datawarehouse using DATASTAGE. How do I do this?
I was browsing Stack Overflow and think I might have a solution to your question. If you create a job to grab all of the IP_ADDRESS's from the file and send them to a BASIC transformer (search for BASIC transformer in DataStage. It is NOT the one that is normally on the palette). From there, set the Stage Variables as 'SetUserStatus() and write out the column name to a peek stage (You don't need the output at all. The SetUserStatus is the important part). This will now allow you to pass up the Command Output (list of IP Addresses) to a Sequence. From the Sequence, start with the job you just created (BASIC transformer job) and link that to a User Variables Activity. In the User Variables Activity stage, Set the name to something like 'IP Address' and Expression as IP_ADDRESS.$UserStatus. You can then use a Loop to take that output that is now a List and send each individual IP Address to an Execute Stage with a Ping command to see if it returns a valid IP Address. If it does return a valid IP then have your job that writes the USER_NAME and IP_ADDRESS to do a 'Select' statement where the IP_ADDRESS = the valid IP_ADDRESS. For the ones that aren't valid, you can send them down a different path and have them write out to '.txt' file somewhere so you know which ones weren't valid. I'm sure you will need a few more steps in there but that should be the gist of it.
Hope my quick stab at your issue helps.
Yes, you can use a transformer or a transformer and a filter to do that, depending on the version of Datastage you're using. If you're using PX, just encode the validation logic in a transformer stage, and then, on the output link set up a filter that doesn't allow the rows to pass forward if they didn't pass the validation logic.
I'm trying to use the map clause with Hive but I'm tripping over syntax and not finding many examples of my use case around. I used the map clause before when I had to process one of the columns of a table using an external script.
I had a python script called, say, run, that took one command line parameter and spit out three space separated values. So I just did:
FROM(MAP
tablename.columnName
USING
'run' AS
result1, result2, result3
FROM
tablename
) map_output
INSERT OVERWRITE TABLE results SELECT *;
Now I have a python script that receives a lot more parameters and tried a few things that didn't worked and couldn't find examples on this. I did the obvious thing:
FROM
(MAP
numAgents, alpha, beta, burnin, nsteps, thin
USING
'runAuthorityMCMC' AS numAgents, alpha, beta, energy, avgDegree, maxDegree, accept
FROM
parameters
) map_output
INSERT OVERWRITE TABLE results SELECT *;
But I got an error A user-supplied transfrom script has exited with error code 2 instead of 0. When I run runAuthorityMCMC, with 6 command line parameters sampled from that table, it works perfectly well.
It seems to me it's trying to run the script without passing the parameters at all. In one of the error messages I got exactly the output I expected if this was the case. What is the correct syntax to do what I'm trying to do?
EDIT:
Confirming - this was part of the error message:
usage: runAuthorityMCMC [-h]
numAgents normalizedBrainCapacity ecologicalPressure
burnInSteps monteCarloSteps thiningRatio
runAuthorityMCMC: error: too few arguments
Which is exactly the output I'd expect with too few arguments. The script should take six arguments.
Ok, perhaps there is a difference of vocabulary here but hive doesn't send the values as "arguments" to the script. They are read in through standard input (which is different than passing something as argument). Also, you can try sending the data to /bin/cat so see what's actually being sent to the hive. If my memory serves me right, the values are sent tab separated and result emitted out from the script is also expected to be tab separated.
Trying printing stuff from stdout (or stderr) in your script, you will see the result in your jobtracker logs. That will help you debug.
For example, I have a list of items and each item has a name. I want to build a single string that contains a comma-separated list of all the names. In most programming languages, I would loop over the items and append to a value outside the list/array. But, I can't figure out any combination of Yahoo! Pipes modules to do it. Maybe I'm missing something obvious, but I also find nothing relevant from Google.
How do I append loop item values to a single value outside the loop?
Or how can I return a single value from a loop that's built with values from every item?
Or what is the correct method to accomplish this in Pipes if it's neither of those?
The best method I've come up with based on help from the Yahoo! group, is to use an Item Builder (item.string = default) --> Loop ( assign all to item.string ). Using another pipe inside the Loop to provide the values to concatenate was also very helpful.
Unfortunately the modules available with Yahoo Pipes alone cannot perform the task you are aiming at. The only solution available currently is to use "web service" module to call an externally hosted script (say in PHP)... the entire pipe content will be sent to the script as POST field "data". You can code the script such that it loops through all items to add the string to a single string and return it after processing.