• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Waiting for a script completion

Vampirex

Newbie
Hello All,
I am facing a small, but annoying trouble: every week I start an automated backup (with ONandroid) with a Tasker profile triggered by power plugged, date and time. After the task ends, I send me a notification and an email as a report of the operation. All could work very well, but unfortunately, the Tasker task ends before the end of the SL4A script (which is a shell script), so I am unable to send the log file with as embedded file to the email.
Can someone tell how to force Tasker to wait for the script completion before sending the email ?
Many thanks.
Best regards.
Daniel.
 
I don't know if it is possible. Is a variable to be set in the shell, can be seen by Tasker ? Otherwise it could be a good solution. The communication between Android environment and Tasker is not very clear for me.
BR.
Daniel.
 
Yes, it is what I have done. But in case of problem in the backup operation, the result is unpredictable, so it is not a good solution.
I looked in the user guide, but it doesn't seem to have any cross environment facility in Tasker.
There is a reference to %CLIP (clipboard) but I cannot use it, as it appears in the user manual, but not usable in the running product.
BR.
Daniel.
 
I'm assuming if it ends before the script finishes, your context is event > power?

I would recommend state > power. That way the profile remains active until state is no longer true.

Then you can send the email as an exit task
 
It is exactly what I do, but the task is finished in a very short time and it takes about 10 minutes to the full backup. I send a notification and an email as an exit task and they are both sent before the end of the script, so it doesn't work.
I wonder if the problem isn't that Tasker starts the SL4A script, but as it seems there is no kind of sync mechanism, the script is ended when the task is launched. A related problem is that I don't see any way to get a return code from the script execution.
Any idea ?
BR.
Daniel.

PS: I have checked in removing the 15 minutes delay I used before sending email, I confirm that the task is ended as soon as the script is launched.
 
Can you export the profile as xml and upload it please? And the script minus your email address?
 
Hello,
Yes, of course.
Enclosed is a TaskerBackup.zip file containing:
-the profile with the 15 minutes delay, named 'DP.Backup.auto.prf.xml',
-the SL4A script (calling proc) is 'Call.DPonandroid.sh', (in fact I renamed it as it is also called DPonandroid),
-and the script itself (which is located on the external card (extSdCard) called 'DPonandroid.sh'.
BR.
Daniel.

PS I replaced my email address by "mymail".
 

Attachments

Have you tried the following????


Profile 1
Context - Power connect
Task - run backup

Profile 2
Context - File modified > mnt/extSdCard/clockworkmod/backup/DPbackupauto/onandroid.txt
Task - Email file
 
It should work, but I wouldn't have any feed back if the backup doesn't go as it should and the file is not recreated, I wouldn't get any email. I stayed 15 days without backup, because my upgrade to JB 4.1.1 was rather 'manly' and I didn't see nothing because my proc had stopped running and I no longer got the backup email. I would be happy to find a way to get the return code from the script. Is it possible to post something like a 'Event Control Block' to communicate a status between asynchronous tasks ? (Remember I am a newbie in Android)!!!
BR.
Daniel.
 
I really don't know the answer to that. You may need help ftothe tasker dev.

I don't fully understand the requirement though. You need a failure email too? I thought not receiving backup success email indicated failure.

Maybe you could describe exactly what you want to happen please. Not in terms of tasker but in terms of actual events.
 
Looking at your script, you have many echo.

Each echo instead could output to a different file name. You could have multiple profiles waiting for multiple files to be edited and a task for each outcome
 
I really don't know the answer to that. You may need help ftothe tasker dev.

I don't fully understand the requirement though. You need a failure email too? I thought not receiving backup success email indicated failure.

Maybe you could describe exactly what you want to happen please. Not in terms of tasker but in terms of actual events.
Very easy, here is the full procedure:
-Every Sunday at 2h AM and if the device is powered on, I start a ONandroid Backup. To do so I rename the last backup folder to "old backup".
-The backup run and creates new folder containing different files following Nand backup rules. At the end, I copy the log file renamed in .txt in the new backup folder.
-Then, I send a notify msg and an email with the log file enclosed. As soon as l get the email, I can read the log file and I know immediately (generally Sunday in the morning ) if the backup is OK.

What I initially wanted is, like on any Unix system or Mainframe (IBM MVS, VM...), be informed with a return code if something is wrong (generally 0 is OK, everything else requires attention). In this case you can send an alert or email, abort the script, execute a program or everything you want.
Unfortunately I was not able to synchronise all these actions and I chose to send the email. But as the Tasker task ends before the backup program, it is sent before the end of the backup, so I introduced a 15 minutes wait time because the backup duration is about 11 minutes and it works. But if for any raison, the backup is longer, it will not work.
My theory is that (very often confirmed by facts) all has to be automatic, specifically in terms of backup. You should be warned only if something is wrong.
Is it clear ?
I had used my good backup when I moved to JB 4.1.1....
BR.
Daniel.
 
Looking at your script, you have many echo.

Each echo instead could output to a different file name. You could have multiple profiles waiting for multiple files to be edited and a task for each outcome
I am trying to work with files events, but up to now, no success.
But on the SGS3 there is a problem as the internal storage is called "sdcard" and the real one is "extSdCard", I have encountered serious trouble with that, so unable to have something working with Tasker file events.
BR.
 
Well actually anything you set on /sdcard will need updating to /sdcard0 on the s3 once you have jellybean.

Anyway, shouldn't have any issue with /sdcard /extSdCard. You browse the file not type it. No problems
 
When I browse its /storage/sdcard0.

Actually you're right, /storage/extSdCard doesn't want to work but I can trigger from file mod from /storage/sdcard0/bump.txt for example...

I really think you need the dev's help on this.
 
Tasker doesn't work very well, in the file area, I mean it is not reliable.
I have done at least 70 tests with all the forms available (deleted, modified, opened, closed, moved): some don't work at all, some others work sometime, but sometime don't. I think this function is not usable. I have tried to send my email with another method: 'mail' or 'mutt' command, but they are not supported by Android.
BR.
Daniel.
 
Hi,
I think that I fixed the problem. Rather than using file action, I used the test function with filename. It was a little more complicated as before but it seems to be reliable. Tasker always give the right data in this way.
Anyway, thank you for trying to help me.
BR.
Daniel.

PS: tell me if you are interested as I can upload to share.
 
Well, it is not very difficult.
I trigger starting the Tasker profile by day of the week, time, and power plugged device .
In the shell script, I begin by housekeeping in my folders, then I launch the Onandroid command, and when the backup ends I copy the log file in my backup folder.
Now, in the Tasker profile, what I want is to wait for backup completion and sending an alert (positive if OK, negative if wrong). So I need to have something telling me if the shell backup script is completed. I chose to test the last file closed, indeed it is the log file, as in the shell script, I copy it myself to the backup folder.
To do that I have a loop (set to one minute) on a filename test. It means every minute I test if the file exists (this is a reliable Tasker function), if no, I launch to another loop, if yes the backup is finished. Then, I send a notification in the notification area and I eMail me the log file.
In addition, if the loop counter goes more than 20 (20 minutes), the backup has probably encountered some troubles, so I stop the task, post a notification and send a negative eMail without the log file, but indicating where to find the original log file (probably not closed).
With this method I am even able to communicate with a Tasker task as I can insert anything I want (return code
 

Attachments

Back
Top Bottom