cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2280
Views
0
Helpful
4
Replies

EEM applet writing to a file on disk and multiple pipes

paul amaral
Level 4
Level 4

I have looked and cant figure out how to do the following in a EEM file. 

 

If i have a command just as, 

action 1.1 cli command "show platform software status control-processor brief | append bootflash:/rpcpu1min.txt"

How can i proceed this command with a header so when the EEM applet emails me the file i know what command was executed to obtain that result.  It would be great if i can just append/echo a command to the file before executing the above command. How can i accomplish this. 

 

Also it seems like EEM doesn't like more than one pipe | per command is there a way to use multiple pipes? for example the following command will not work with cli command with double pipes. 

 

sh proc cpu sort | in xxx | append bootflash:/rpcpu1min.txt

 

 

TIA, Paul 

 

 

 

4 Replies 4

Seb Rupik
VIP Alumni
VIP Alumni

Hi there,

If I am understanding you right, why not assign the cli command to a variable and then reference it in the applet. Like:

action 0.1 set CMD01 "show platform software status control-processor brief | append bootflash:/rpcpu1min.txt"
action 1.1 cli command "$CMD01

...you can then use $CMD01 elsewhere.

 

cheers,

Seb.

problem is when you have multiple pipes in the command it doesnt work. 

 

show in desc | in something | append flash:/file name 

The above command doesnt seem to work with multiple pipes. 

 

Paul 

 

 

 

 

Hi Paul,

As you have discovered the function of the second pipe differs from what you expect in a UNIX terminal. The second pipe is actually an OR operator.

 

If you just want to write a string to a file outside of the action cli command statement, then you will need to assign the result to a variable and use the action file command. Something like this (untested!!) :

action 0.1 set CMD01 "show platform software status control-processor brief | append bootflash:/rpcpu1min.txt"
action 1.1 cli command "$CMD01"
action 1.2 file open fh flash:some_output.txt w
action 1.3 file write fh $_cli_result
action 1.4 file close fh

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/eem/command/eem-cr-book/eem-cr-a1.html#wp3071812405

 

I don't have an IOS device nearby to test this on, so I look forward to hearing back from you :)

 

cheers,

Seb.

Seb, Thank you I will test and post results to the group, reading the doc you sent me it should work.

 

Paul