Sub Globals
Dim SiteNoIp As String
Dim job2 As HttpJob
Dim lb As Label
Dim ButtonTest As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'========================================
SiteNoIp = "http://nomesito.no-ip.com/"
'========================================
Activity.Title = "How to run scripts .py and .sh"
Activity.Color = Colors.White
ButtonTest.Initialize ("ButtonTest")
Activity.AddView (ButtonTest,5dip,20dip,140dip, 60dip)
ButtonTest.text = "TEST"
lb.Initialize ("Lb")
Activity.AddView (lb,5dip,120dip,200dip,100dip)
lb.Text = "......."
lb.TextColor = Colors.Black : lb.color = Colors.white
End Sub
Sub ButtonTest_click
job2.Initialize("Job2", Me)
'
'--- test 1 : OK
'job2.PostString(SiteNoIp & "hello.php", "a")
' hello.php
'<?php
' Print "Hello, World!\n in /var/www/html";
'?>
'--- test 2 : almost OK
'job2.PostString(SiteNoIp & "hello.sh", "a")
' hello.sh
' #!/bin/bash
' echo Hello World
'--- test 3 : NO
job2.PostString(SiteNoIp & "print2.php", "p1=first value&p2=value2")
' print2.php
' <?php
'$p1 = $_GET["p1"];
'$p2 = $_GET["p2"];
'print ("I've received $p1 and $p2");
'?>
'--- test 4 : NO
job2.PostString(SiteNoIp & "testwrite.php", "")
' testwrite.php
'<?php
'echo shell_exec('testwrite.sh');
'?>
'
' testwrite.sh
'#!/bin/bash
'echo OK > testwrite.txt
'
' testwrite.txt
' Lorem ipsum dolor sit amet,
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job2"
Log(Job.GetString)
lb.Text = Job.GetString
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub