external notifications (aka email from an ash script?)

razorboy

Member
Hi guys,
I've been working on my automation and I'm curious if there's a way to send out (actual) email from an ash script. I'd like to notify myself if there's an error.

If there's not a direct way, I just set up a new linux server, so I could use the "mail" command but is there a way to send out standard bash commands?
 

lostcalpolydude

Developer
Staff member
That feature would have very limited use, since I expect that most internet plans block outgoing port 25 unless you go to the trouble of getting them to unblock it for you.

Another approach might be to write something to a file (in the data folder probably) and have a cron job checking for it regularly. However, any unexpected errors are likely to prevent the script from doing anything you would want, even if mafia could send an email.
 

Grotfang

Developer
You could always stream all output into a file

Code:
java -jar /home/<dir>/KoLmafia.jar startup.txt --CLI > /home/<dir>/output

That way an error causing an abort/error state would still be picked up on a cron job. Data files are useful, but it sounds as though you want something to picked up on if something has an error, which I assume means an abort. I also assume if you are running this on a server (and not actually viewing stuff) that you will be running it with the --CLI argument.

EDIT: As an example, the way I run my clan's clanbot is with the following:

Code:
/user/bin/nohup java -DUseCWDasROOT -jar -Djava.awt.headless=true /home/Grotfang/GsL/KoLmafia-GsL.jar logingsl.txt --CLI > /home/Grotfang/outputgsl &

Note this also disassociates the process from your account.
 
Last edited:

Camber

Member
Another approach might be to write something to a file (in the data folder probably) and have a cron job checking for it regularly. However, any unexpected errors are likely to prevent the script from doing anything you would want, even if mafia could send an email.

Or, you could have the functioning script write a 'heartbeat' to a file, and have cron monitor the date/time on that file. If too old, you have a probem.
 

zeryl

New member
Similar to the heartbeat, could have it write the log, or a "status" message (every minute?) to your web root, to allow for seeing the status remotely. Could even be written in such a way (python, php, etc), to re-start the bot if needed, from the page (obviously would want some authentication mechanism if you allow for that).

Pretty simple and quick to do via PHP, and I would assume the same for Python.
 
Top