Go Back   Android Forums > Android Discussion > Android Applications > Tasker

Like Tree1Likes
  • 1 Post By Vampirex

test: Reply
 
LinkBack Thread Tools
Old October 28th, 2012, 01:57 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default Waiting for a script completion

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.

Advertisements
Vampirex is offline  
Reply With Quote
sponsored links
Old October 28th, 2012, 02:41 PM   #2 (permalink)
Senior Member
 
bberryhill0's Avatar
 
Join Date: Jan 2010
Location: Rhinelander, WI> Wayzata, MN>Sisters, OR
Posts: 2,456
 
Device(s): Q9c, Eris xtrROM 4.6.5, Droid Concepts 11, Incredible 2 EclipticSense
Carrier: Not Provided

Thanks: 855
Thanked 362 Times in 322 Posts
Default

Can you set a variable at the end of the script that Tasker waits for?
__________________
My Eris apps
bberryhill0 is online now  
Reply With Quote
Old October 28th, 2012, 03:30 PM   #3 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Reply With Quote
Old October 28th, 2012, 03:42 PM   #4 (permalink)
Senior Member
 
bberryhill0's Avatar
 
Join Date: Jan 2010
Location: Rhinelander, WI> Wayzata, MN>Sisters, OR
Posts: 2,456
 
Device(s): Q9c, Eris xtrROM 4.6.5, Droid Concepts 11, Incredible 2 EclipticSense
Carrier: Not Provided

Thanks: 855
Thanked 362 Times in 322 Posts
Default

I don't know scripts. You could also have Tasker wait for however many seconds it takes the script to finish.
bberryhill0 is online now  
Reply With Quote
Old October 28th, 2012, 04:21 PM   #5 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Reply With Quote
Old October 28th, 2012, 05:11 PM   #6 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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
SUroot is offline  
Reply With Quote
Old October 28th, 2012, 06:31 PM   #7 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Last edited by Vampirex; October 28th, 2012 at 06:50 PM.
Reply With Quote
Old October 29th, 2012, 02:53 AM   #8 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

Can you export the profile as xml and upload it please? And the script minus your email address?
SUroot is offline  
Reply With Quote
Old October 29th, 2012, 06:10 AM   #9 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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".
Attached Files
File Type: zip TaskerBackup.zip (1.6 KB, 10 views)
SUroot likes this.
Vampirex is offline  
Reply With Quote
Old October 29th, 2012, 09:08 AM   #10 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

Thanks. I'll have a look tonight if I get chance.
SUroot is offline  
Reply With Quote
sponsored links
Old October 29th, 2012, 09:11 AM   #11 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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
SUroot is offline  
Reply With Quote
Old October 29th, 2012, 12:37 PM   #12 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Last edited by Vampirex; October 29th, 2012 at 12:49 PM.
Reply With Quote
Old October 29th, 2012, 02:16 PM   #13 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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.
SUroot is offline  
Reply With Quote
Old October 29th, 2012, 02:21 PM   #14 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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
SUroot is offline  
Reply With Quote
Old October 29th, 2012, 04:39 PM   #15 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by SUroot View Post
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.
Vampirex is offline  
Reply With Quote
Old October 29th, 2012, 05:05 PM   #16 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by SUroot View Post
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.
Vampirex is offline  
Reply With Quote
Old October 29th, 2012, 05:39 PM   #17 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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
SUroot is offline  
Reply With Quote
Old October 29th, 2012, 06:06 PM   #18 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

If you use sdcard0 you have to use /storage/sdcard0/.
Is it a problem with /mnt/sdcard/ ?
BR.
Daniel.
Vampirex is offline  
Reply With Quote
Old October 29th, 2012, 06:29 PM   #19 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

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.
SUroot is offline  
Reply With Quote
Old October 30th, 2012, 03:23 AM   #20 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

What do you mean by "I really think you need the dev's help on this."?
BR.
Daniel.
Vampirex is offline  
Reply With Quote
sponsored links
Old October 30th, 2012, 05:48 AM   #21 (permalink)
ROM Developer
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

The developer of Tasker. You need his help.
SUroot is offline  
Reply With Quote
Old October 30th, 2012, 06:24 AM   #22 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Reply With Quote
Old October 30th, 2012, 07:00 PM   #23 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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.
Vampirex is offline  
Reply With Quote
Old October 30th, 2012, 07:42 PM   #24 (permalink)
Senior Member
 
bberryhill0's Avatar
 
Join Date: Jan 2010
Location: Rhinelander, WI> Wayzata, MN>Sisters, OR
Posts: 2,456
 
Device(s): Q9c, Eris xtrROM 4.6.5, Droid Concepts 11, Incredible 2 EclipticSense
Carrier: Not Provided

Thanks: 855
Thanked 362 Times in 322 Posts
Default

Interested. Let us know more about how you did it!
bberryhill0 is online now  
Reply With Quote
Old October 31st, 2012, 06:33 AM   #25 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Sep 2012
Location: Normandy, France
Posts: 32
 
Device(s): Galaxy S3 GT-I9300
Carrier: Not Provided

Thanks: 1
Thanked 2 Times in 2 Posts
Default

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…) in the log file or create another file or ….
But for now, I met my goal and my backup is fully automated.
Enclosed is a zip file:
-DP.BackupAuto.prf.xml is the Tasker profile,
-SU.DPonandroidAuto.sh is the Tasker launched (SU mode) shell script and
-DPonandroid.sh is the script shell itself.
BR.
Daniel.

PS I apologise for my English, and I hope it is clear enough...
Attached Files
File Type: zip DP.Backup.auto.zip (1.2 KB, 3 views)
Vampirex is offline  
Reply With Quote
The Following User Says Thank You to Vampirex For This Useful Post:
bberryhill0 (October 31st, 2012)
Reply
Tags
script completion, script end


Go Back   Android Forums > Android Discussion > Android Applications > Tasker
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:17 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.