rc = stream(SemaMailer, 'c', 'close')
end /* This is the End of the Do for the Endless Loop */
/* exit */
/* ------------------------------------------------------ */
/* ---------------------------------------------- */
/* This function makes a connection to the remote mail server to */
/* check that the dialup connection has been made successfully. */
PingServer: procedure expose server. domain RemoteServer CRLF
say 'PingServer'
iTimes = 0
iRc = 1
rc = SockGetHostByName(RemoteServer, "host.!")
if (rc = 0) then do
say 'Unable to resolve hostname'
call LINEOUT DialupLogFile, date() time() 'Unable to resolve hostname ...'
return iRc
end
/* save the ip address */
server.!addr = host.!addr
do while (iTimes < 30)
say 'save the IP address ...'
if (iTimes > 0) then do
call SysSleep(10) /* go to sleep for a while - 10
seconds */
end
/* create a new socket */
say 'Creating socket ...'
sock = SockSocket('AF_INET', 'SOCK_STREAM', 0)
if (sock < 0) then do
iTimes = iTimes + 1
iterate
end
/* connect to the remote server */
say 'Connecting to server ...'
call SysSleep(15) /* go to sleep for a while - 15
seconds */
rc = SockConnect(sock, "server.!")
if (rc < 0) then do
say 'Error on SockConnect =' errno
rc = SockClose(sock)
iTimes = iTimes + 1
iterate
end
/* get the greeting */
say 'Getting the greeting ...'
rc = SockRecv(sock, greeting, 1024)
if (rc < 0) then do
rc = SockClose(sock)
iTimes = iTimes + 1
iterate
end
say 'Server greeting: ' greeting
/* Send a nice reply */
rc = SockSend(sock, 'ehlo'CRLF)
if (rc < 0) then do
rc = SockClose(sock)
iTimes = iTimes + 1
iterate
end
/* get the response */
rc = SockRecv(sock, greeting, 1024)
if (rc < 0) then do
rc = SockClose(sock)
iTimes = iTimes + 1
iterate
end
say 'Server helo response: ' greeting
/* And a closing response */
rc = SockSend(sock, 'quit'CRLF)
if (rc < 0) then do
rc = SockClose(sock)
iTimes = iTimes + 1
iterate
end
/* Must have completed ok */
iRc = 0
leave
end
return iRc
/* end of function */
/* ------------------------------------------------------ */
>==============================================================================
=========
And now the first questions :
1ø) At the beginning of the script you find those lines :
KillDialer
call SysSleep(2)
kill inetmail
call SysSleep(2)
kill pop3d
call SysSleep(2)
kill smtpd
(I've removed the lineout lines).
As you can see, I kill, using "go.exe", four applis (the dialer,
Inetmail, pop3d and smtpd).
I would like first to kill them, ONLY if they run.
Actually the script tries to kill them each time it is run, and the output
gives some error warnings (the script works but I do not like those
warning) . This is what I get :
--------------------------------------------------------------------
...we will try to shutdown dialer and mail server before we start...
--------------------------------------------------------------------
[E:\tmp]e:\injoy\killjoy.exe
[E:\tmp]go.exe -k INETMAIL
GO! v1.5 - (c) 1993-95 by Carsten Wimmer
Querying pid for process ... Error ...
[E:\tmp]go.exe -k POP3D
GO! v1.5 - (c) 1993-95 by Carsten Wimmer
Querying pid for process ... Error ...
[E:\tmp]go.exe -k SMTPD
GO! v1.5 - (c) 1993-95 by Carsten Wimmer
Querying pid for process ... Error ...
How can I modify the script to launch that kill function only if the
appli to kill is running ?
(I have added to the script the variable "CheckIfRunning" but I didn't add the
lines for it into the code itself).
2ø) What are the lines to add to the script to have it to calculate the time
online. The script gives me the time it is for each process it is executing,
but I would like it to calculate the exact time I'm connected to my provider,
and with the cost of each minute connected, I would be able to know exactly
how much it costs me. (I'm charged about 0.25 $ per mn).
Would it be possible to have something like that (see below) in the log file :
11 Oct 1999 03:11:55 . Sleeping for 13500 seconds...
11 Oct 1999 03:11:55 End of the script
11 Oct 1999 03:11:55 Total time connected for this run : 3' 25". Cost : 0.75$
3ø) I've just taken a look at the log file, and this is what I saw ;-( :
----/ DialUp Script v.1.6 rev.0.05 : Jeudi 7 Oct 1999 - 18:34:36 /---
7 Oct 1999 18:34:36 Started dialup up process ...
7 Oct 1999 18:34:36 dialer, if running, is killed.
7 Oct 1999 18:34:37 inetmail, if running, is killed.
7 Oct 1999 18:34:38 pop3d process, if running, is killed.
7 Oct 1999 18:34:39 smtpd process, if running, is killed.
7 Oct 1999 18:34:42 . Starting the Internet Dialer ...
7 Oct 1999 18:34:43 We can resolve hostnames, connection is up...
7 Oct 1999 18:34:43 InetMail, Pop3d and Smtpd are started...
7 Oct 1999 18:34:44 . Starting of the PingServer procedure ...
7 Oct 1999 19:33:56 . Warning : Unable to connect to remote Sever.
Skipping connection.
7 Oct 1999 19:33:56 and we go to sleep for a while - 10 seconds.
7 Oct 1999 19:34:06 . Hanging up ...
7 Oct 1999 19:34:06 we kill the Dialer, Crude but necessary ...
7 Oct 1999 19:34:07 InetMail is killed.
7 Oct 1999 19:34:10 Pop3d process is killed.
7 Oct 1999 19:34:11 Smtpd process is killed.
7 Oct 1999 19:34:11 . Sleeping for 10800 seconds...
7 Oct 1999 19:34:11 End of the script
As you can see, 6.34pm : Starting of the PingServer Procedure
BUTTTTTTTT, 7.33 pm Warning : Unable ;.....
ONE HOUR LATER ;-(((((((((
I've to pay for ONE HOUR ;-(
Is there a way to have the script to check the com port or something
else, but I would like to have more secure ;-(((
4ø) This is an example of a problem I have from time to time :
I started the script, but Injoy hang up after running out of time. ( I setted
up its timer to 5 minutes.
In the window the script was running, I've got the following output :
>------------------------------------
--------------------------------------------------------------------
Starting dialer ...
...starting InJoy dialer in another session...
--------------------------------------------------------------------
[E:\injoy]start "Internet Dialer" /C e:\injoy\in-joy.exe auto
...let's sit'n'wait till connection is established before we try
anything...
...testing if a link has been established...
..we can resolve hostnames, connection is up...
--------------------------------------------------------------------
Check for a live connection, starting mail processing ...
--------------------------------------------------------------------
PingServer
Creating socket ...
Connecting to server ...
Error on SockConnect = ETIMEDOUT
Creating socket ...
Connecting to server ...
Getting the greeting ...
>----------------------------------
And the things stayed that way forever ;;-(
The script seems to wait for the greeting, but Injoy was stopped.
How can I tell the script to kill everything after a while if
something like that happens ???
5ø) Another kind of problem :
Sometimes, in the window the script is running, the script seems to be
frozen (?) as it displays :
PingServer
Creating socket ...
Connecting to server ...
Getting the greeting ...
Injoy is well connected, but I setted up the time to 5 minutes. (I pay
for every second I stay on line). The time has run out, then Injoy
has disconnected, but the script was always showing the same line :
"Getting the greeting....".
Injoy has restarted, connect to my isp and wait for the timer to run
out (5 minutes again)., but the script was always waiting for the
"greeeting", and things stayed that way, injoy has disconnected, then
restart, etc....
As I have to run this script in an unattended way, it's impossible to
have the things to run that way;
What are the changes to do ?
I guess, it's enough for a first message. Really, thank you to all of you who
will be able to help me to make that script strong enuf to run by itself and
in a secure way for one month.
Bye, Francois!
Email: fmas@celtes.com
Web : http://www.worldnet.net/~island/
---
* Origin: Island's BBS, a Node in the Atlantic Ocean (2:326/2)
|