TheUnexplained
Posted
#1
(In Topic #1169)
Trainee
My gambas program is creating an html file that is copied the the /var/www/html folder(THE WEBSITE).
I'm using this to monitor room temperature in a workshop.
While logged into my laptop remotely or local:
The html file is created perfectly and generates a link button which displays the historical temperatures from a file on THE WEBSITE.
This link button includes the ipaddress of the laptop with the name of the file with the history recrods in it.
it works perfectly. Also I have other computers (hardwired ethernet, Not wireless like the laptop pc) where this problem does not exist.
<!DOCTYPE html>
<!-- -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8 "/>
<title></title>
<meta name= "generator" content="LibreOffice 7.5.5.2 (Linux)"/>
<meta name= "created" content="2023-08-05T08:42:00.296569589"/>
<meta name= "changed" content="2023-08-05T08:53:08.939254815"/>
<style type= "text/css">
@page { size: 8.0in 11in; margin: 0.79in }
p { line-height: 100%; margin-bottom: 0.1in; background: transparent; background: transparent }
h1 { margin-bottom: 0.08in; background: transparent; page-break-after: avoid }
h1.western { font-family: "Liberation Sans", sans-serif; font-size: 18px; font-weight: bold }
h1.cjk { font-family: "Noto Sans CJK SC"; font-size: 24px; font-weight: bold }
h1.ctl { font-family: "Lohit Devanagari"; font-size: 24px; font-weight: bold }
a:link { color: #000080; text-decoration: underline }
a:visited { color: #800000; text-decoration: underline }
</style>
<meta http-equiv="refresh" content="30" >
</head>
<body lang= "en-US" link="#000080"vlink= "#800000" dir="ltr"><p style="line-height: 100%; margin-bottom: 0in">
<br/>
</p>
<p style= "line-height: 100%; margin-bottom: 0in"><br/>
</p>
<h1 class="western" align="center"><font face="Liberation Serif, serif" >Workshop___________________ 48°</font></h1>
<h1 class="western" align="center"><font face="Liberation Serif, serif" >Wednesday 01/03/2024 11:23:58 am</font></h1>
<p align= "center" style= "line-height: 100%; margin-bottom: 0in"><a href=
HERE IT DOES INSERT THE IPADDRESS.
|
"http://192.168.1.34/ShowTempMonStat.html"><font size= "5" style= "font-size: 24px
"> Show history readings</font></a></p >
</body>
</html>
Running the applicationn as root when laptop reboots:
With this set up I created a cron job to reboot the laptop at the beginning of each day and start the gambas executible to do all this.
However, when the html page is created it will not imbed the ip address into it. It just leaves a blank spot and subsequently the link button fails.
<!DOCTYPE html>
<!-- -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8 "/>
<title></title>
<meta name= "generator" content="LibreOffice 7.5.5.2 (Linux)"/>
<meta name= "created" content="2023-08-05T08:42:00.296569589"/>
<meta name= "changed" content="2023-08-05T08:53:08.939254815"/>
<style type= "text/css">
@page { size: 8.0in 11in; margin: 0.79in }
p { line-height: 100%; margin-bottom: 0.1in; background: transparent; background: transparent }
h1 { margin-bottom: 0.08in; background: transparent; page-break-after: avoid }
h1.western { font-family: "Liberation Sans", sans-serif; font-size: 18px; font-weight: bold }
h1.cjk { font-family: "Noto Sans CJK SC"; font-size: 24px; font-weight: bold }
h1.ctl { font-family: "Lohit Devanagari"; font-size: 24px; font-weight: bold }
a:link { color: #000080; text-decoration: underline }
a:visited { color: #800000; text-decoration: underline }
</style>
<meta http-equiv="refresh" content="30" >
</head>
<body lang= "en-US" link="#000080"vlink= "#800000" dir="ltr"><p style="line-height: 100%; margin-bottom: 0in">
<br/>
</p>
<p style= "line-height: 100%; margin-bottom: 0in"><br/>
</p>
<h1 class="western" align="center"><font face="Liberation Serif, serif" >Workshop___________________ 48°</font></h1>
<h1 class="western" align="center"><font face="Liberation Serif, serif" >Wednesday 01/03/2024 11:23:58 am</font></h1>
<p align= "center" style= "line-height: 100%; margin-bottom: 0in"><a href=
HERE IT DOES NOT INSERT THE IPADDRESS.
|
"http:///ShowTempMonStat.html"><font size= "5" style= "font-size: 24px
"> Show history readings</font></a></p >
</body>
</html>
I hope someone might have a clue for what is happening.
The only dumb questions are the ones that never get asked.
Posted
Guru

what method exactly?
Posted
Guru

<IMG src="https://www.cogier.com/gambas/Startups.png">
</IMG>
Posted
Trainee
BruceSteers said
How are you getting and inserting the ip address?
what method exactly?
Hey; thanks for the reply.
I get the ip address by using Shell( hostname -I ) to myip:
Instead of using a return I just create a global variable named myip.
When this Sub is called it just updates it.
I put the Loop in it to make shure, if the system was not settled down after startup, to set the ip.
Public Sub Get_myip()
If Dbug = "yes" Then Print "get_myip() has been reached"
Dim colspace As Integer
loopit:
Shell "hostname -I" To myip
If myip = "" Then Goto loopit
colspace = InStr(myip, " ")
myip = Left$(myip, colspace - 1)
Print "this is my id address: " & myip
End
The only dumb questions are the ones that never get asked.
Posted
Trainee
cogier said
It's possible that when your program starts on boot the system is not quite ready yet. I suggest you allow some time for it to settle down before you start your program. I use Linux Mint which allows for a period of time after boot before your program starts. You can see below that even some of the system programs are delayed.
<IMG src="https://www.cogier.com/gambas/Startups.png"></IMG>
Thanks for the suggestion.
I will look into that.
Currently I start the program with a cron job setup.
The only dumb questions are the ones that never get asked.
Posted
Guru

Posted
Regular

Code (gambas)
b
Posted
Guru

Sometimes a command works better if you use bash instead of the default sh shell, Don't ask me why.
In the following example i try to get the xdg videos dir first using the default gambas sh Shell , then i change to bash…
Code (gambas)
sh command returns
bash command returns /home/bonus/Videos
And the other Bruce's suggestion of using a retry counter so the code does not get stuck in the loop if it never gets a result is very wise
Code (gambas)
1 guest and 0 members have just viewed this.


