Curl and write custom result to file


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Curl and write custom result to file

I have the following script,
Code:
for i in $(cat MyWebApps); do curl -u manager:tH1s1s4f3k3p4ssw0Rd http://10.10.10.10:7529/manager/jmxproxy/"?get=Catalina:type=Manager,context=/$i,host=localhost&att=activeSessions"; done

Which gives me an output like this
Code:
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp1,host=localhost' - activeSessions = 2
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp2,host=localhost' - activeSessions = 5
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp3,host=localhost' - activeSessions = 180
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp4,host=localhost' - activeSessions = 300
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp5,host=localhost' - activeSessions = 72
OK - Attribute get 'Catalina:type=Manager,context=/MyWebApp6,host=localhost' - activeSessions = 89

Based on the output, I need to write in a csv file as following, can you help on this?
Code:
2019-04-19-10:05,MyWebApp1,2
2019-04-19-10:05,MyWebApp2,5
2019-04-19-10:05,MyWebApp3,180
2019-04-19-10:05,MyWebApp4,300
2019-04-19-10:05,MyWebApp5,72
2019-04-19-10:05,MyWebApp6,89

INFO:
SUSE Linux Enterprise Server 11
Thank you.

Last edited by charli1; 04-19-2019 at 05:04 AM..
# 2  
Any attempts / ideas / thoughts from your side? What have you learned from your other threads, e.g. this one?


You might want to add your OS, shell, and tools' versions so people know what can be done and what to avoid.
# 4  
Thanks for the server info. What about the other questions?
# 5  
I tryied multiple versions of the script adding awk grep etc, none worked, so i asked for help, let me know if you have any ideas,
thank yuo.
# 6  
Show your attempts and where and how they failed.
# 7  
Code:
for i in $(cat MyWebApps); do curl -u manager:tH1s1s4f3k3p4ssw0Rd http://10.10.10.10:7529/manager/jmxproxy/"?get=Catalina:type=Manager,context=/$i,host=localhost&att=activeSessions" |awk -F, '{print $6}'; done

And prints
Code:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    97  100    97    0     0  21661      0 --:--:-- --:--:-- --:--:-- 32333
9
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    96  100    96    0     0  11370      0 --:--:-- --:--:-- --:--:-- 13714

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Compare 2 file and write result
Akshay Hegde
Hi friends...I have 2 files, file1.txt and reference.txt I could able to find difference using diff and following command awk 'NR == FNR { A=1; next } !A' reference.txt file1.txt above command listing data which is not in reference.txt 12.12 87 11.95 88 11.83 89 12.55 84...... Shell Programming and Scripting
12
Shell Programming and Scripting
Script to write result to a file
Shaan_Shaan
Hello, How can I run this script every 1 hour and save its result to result.txt ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' Regards Shaan... Shell Programming and Scripting
5
Shell Programming and Scripting
Write result to output file
bluejean1976
Good morning everybody, Beeing an absolute newbie in shell scripting I would like to look for some help here. I would like to read an external text file and format the data and write it to an output file. What I was trying to do was to display the result (this worked). But now I...... Shell Programming and Scripting
1
Shell Programming and Scripting
How to write result of a query to more than 1 .csv
Jassz
If the result of the query is greater than say, 50,000 then the next 50,000 should be written to the second file and so on. Is it possible?... Shell Programming and Scripting
1
Shell Programming and Scripting
script to output curl result as html
squidusr
hi, new to scripting and would like to know how can I have a script which will curl a few URLs and have the results such as the URLs being curled, dns lookup time, connection time, total time, etc save in a html format in a form of table with column and rows. thank you.... Shell Programming and Scripting
4
Shell Programming and Scripting