hi team,
Sorry for spamming this board with a silly question.
I want to get a single line command and, let's say, "single command" script for gathering info about server and forming output to dokuwiki.
I have a command, but echo do not print new line, to make dokuwiki human readable code, I need it to output a new line in an output where specified \n.
Here is my line:
Code:
echo "====== `hostname` ====== \n ===== Description ===== \n ===== OS ===== \n <code>`uname -a ; cat /etc/redhat-release`</code> \n ===== Net ===== \n ==== ip a s ==== \n <code>`/sbin/ip a s`</code> \n ==== ip r s ==== \n <code>`/sbin/ip r s`</code> \n ==== netstat -tanupl or -tanul ==== \n <code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code> \n </code>"
I know, that I can do something like:
Code:
echo "====== `hostname` ======
===== Description =====
===== OS =====
<code>`uname -a ; cat /etc/redhat-release`</code>
===== Net =====
==== ip a s ====
<code>`/sbin/ip a s`</code>
==== ip r s ====
<code>`/sbin/ip r s`</code>
==== netstat -tanupl ====
<code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code>"
But I want it to have in a single line, to make it brilliant
.
Thankyou for your help.
And as advantage, would be additional info which I can get
I also thought about dmidecode... but not sure if it will be useful...
Thank you again for reading it till the end!!! Woohoo!
edited, command, added if, but I think it's not working.
edited 2, if issue fixed.
edited 3, Correct answer:
Code:
echo -e "====== `hostname` ====== \n ===== Description ===== \n ===== OS ===== \n <code>`uname -a ; cat /etc/redhat-release`</code> \n ===== Net ===== \n ==== ip a s ==== \n <code>`/sbin/ip a s`</code> \n ==== ip r s ==== \n <code>`/sbin/ip r s`</code> \n ==== netstat `if [[ $EUID -eq 0 ]]; then echo '-tanupl' ; esle echo '-tanul' ; fi` ==== \n <code>`if [[ $EUID -eq 0 ]]; then netstat -tanupl ; else netstat -tanul ; fi`</code>"