I am executing a shell script from PHP with shell_exec like this:
$output = shell_exec('./intnacstat.sh "'.$ip.'" 2>&1');
intnacstat.sh result is:
interface GigabitEthernet0/8
description ISE dot1x Port
switchport access vlan 70
switchport trunk encapsulation dot1q
switchport trunk native vlan 70
switchport trunk allowed vlan 256
switchport mode trunk
authentication event fail action next-method
authentication host-mode multi-host
authentication open
authentication order dot1x mab
authentication priority dot1x mab
authentication port-control auto
authentication periodic
authentication timer reauthenticate server
authentication timer inactivity server
authentication violation restrict
mab
So every command is on separate line.
But when I echo $output on PHP everything is on a single line, basically unreadable:
"show run interface G0/8 Building configuration... Current configuration : 767 bytes ! interface GigabitEthernet0/8 description ISE dot1x Port switchport access vlan 70 switchport trunk encapsulation dot1q switchport trunk native vlan 70 switchport trunk allowed vlan 256 switchport mode trunk authentication event fail action next-method authentication host-mode multi-host authentication open authentication order dot1x mab authentication priority dot1x mab authentication port-control auto authentication periodic authentication timer reauthenticate server authentication timer inactivity server authentication
Can someone tell me how to echo the $output to also add line brakes at the end of the command. Or any other way this can be done.
intnacstat.sh result is:you mean results or contents ?