Community discussions

MikroTik App
 
ninet
just joined
Topic Author
Posts: 14
Joined: Mon Aug 10, 2009 3:58 pm

Show flags in ssh output (Array)

Wed Nov 25, 2009 5:36 pm

Hello,

After playing around with API I have decided to work with ssh, using ssh2_shell. Executing scripts works fine, a bit more tricky is with report, and here is one question for you guys: How I can read Flags from array?

For example, If I wanna get list of users I`ll simple ran
explode(';', conn_exec(":put [/user print as-value]")); 
but I can`t see if user is disabled or enabled? Same logic is for everything whenever a need to read flags....

Output would be array
Array ( 
[0] => .id=*1
[1] => comment=
[2] => name=admin
[3] => group=full
[4] => address=0.0.0.0/0
[5] => .id=*2
[6] => comment=
[7] => name=some_other_user
[8] => group=full
[9] => address=0.0.0.0/0
...
and it`s easy to deal with it, but I can`t figure out how to read flag values..

Thank you.
Strahinja
 
bobertperry
newbie
Posts: 44
Joined: Tue Jan 06, 2009 4:05 am

Re: Show flags in ssh output (Array)

Thu Nov 26, 2009 8:24 pm

Print displays an x next to there line of they are disabled. Have your code look for that. Or use export, not print.
 
ninet
just joined
Topic Author
Posts: 14
Joined: Mon Aug 10, 2009 3:58 pm

Re: Show flags in ssh output (Array)

Fri Nov 27, 2009 12:37 pm

solved! :D
$test = explode(';', conn_exec(":put [/user get ".$user." disabled]"));
print_r ($test);
will give the output:
Array ( [0] => false ) 
if user $user is disabled, otherwise will be true.