//Called when application is started.function OnStart(){ //Create a layout with objects vertically centered. lay = app.CreateLayout( "linear", "VCenter,FillXY" ); lay.SetBackColor("Red");
//Create a text control to show data log. txt = app.CreateText( "...", 0.9, 0.9, "Multiline,Left" ); txt.SetTextColor( "White" ); lay.AddChild( txt ); //Create a text label and add it to layout.var shell = app.CreateSysProc( "sh" ); var cmd = "ping -c3 8.8.8.8 > /sdcard/ping.txt"; shell.Out( cmd + "\n" );
txt.SetText( shell );
app.AddLayout( lay ); }
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
lay.SetBackColor( "#333333" );
//Create an text edit box for entering commands.
edt = app.CreateTextEdit( "www.google.com", 0.8, -1, "SingleLine" );
edt.SetMargins( 0,8,0,8, "dip" );
edt.SetHint( "address/ip" );
lay.AddChild( edt );
//Create a scroller for log window.
scroll = app.CreateScroller( 0.95, 0.7 );
scroll.SetBackColor( "black" );
lay.AddChild( scroll );
//Create text control for logging (max 500 lines).
txt = app.CreateText( "", 2,-1, "Log,Monospace" );
txt.SetBackColor( "black" );
txt.SetLog( 500 );
scroll.AddChild( txt );
//Create a button
btn = app.CreateButton( "Ping", 0.3, 0.1 );
btn.SetMargins( 0,8,0,8, "dip" );
btn.SetOnTouch( btn_OnTouch );
lay.AddChild( btn );
app.AddLayout( lay );
}
//Called when user touches our button.
function btn_OnTouch()
{
var s = app.SysExec( "ping -c 1 " + edt.GetText() );
txt.Log( s );
}
the cmd "ping -c 1" obviously get all of the information, is there a way of just getting part of that?
i have set it to ping once per second,
and i only really need a yes/no.
so i can add them up and show uptime + downtime.
I will post on here when finnished, i am told it is a useful tool for I.T. folk...
cheers again,
Lee
lay.SetBackColor( "#333333" );
//Create an text edit box for entering commands.
edt = app.CreateTextEdit( "www.google.com", 0.8, -1, "SingleLine" );
edt.SetMargins( 0,8,0,8, "dip" );
edt.SetHint( "address/ip" );
lay.AddChild( edt );
//Create a scroller for log window.
scroll = app.CreateScroller( 0.95, 0.7 );
scroll.SetBackColor( "black" );
lay.AddChild( scroll );
//Create text control for logging (max 500 lines).
txt = app.CreateText( "", 2,-1, "Log,Monospace" );
txt.SetBackColor( "black" );
txt.SetLog( 500 );
scroll.AddChild( txt );
app.AddLayout( lay );
setInterval(btn_OnTouch,1000);
}
scroll.ScrollTo( 0, biggest);
}
Try adding this at the top of your code.
_AddPermissions("Network");