pyraylos
Posts: 6
Joined: Thu Feb 11, 2016 4:42 pm

notification when task is done

Sun Jul 10, 2016 2:18 pm

hi. i often upload files from my rpi2 to the cloud through terminal and it takes a long time. is there a way to get a notification(to my mac) when the task is done?

W. H. Heydt
Posts: 14048
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: notification when task is done

Sun Jul 10, 2016 7:53 pm

If you write a shell script and include notification code following the upload process, then, yes.

Almost all unix/Linux programs are designed to work silently. That is, no progress, no completion notice, though most of them will give a status value on exit so you can query that to determine if the program ran sucessfully or not.

Edit to add...this is where "verbose" flags come in. They will cause programs to give more (sometimes a *lot* more) feedback.

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: notification when task is done

Mon Jul 11, 2016 4:18 am

pyraylos wrote:hi. i often upload files from my rpi2 to the cloud through terminal and it takes a long time. is there a way to get a notification(to my mac) when the task is done?
You are not using the terminal when uploading something, by using a Cronjob or such. If you are using a GUI with Linux, everything is going to run on the OS, not in X-Windows. You just need to make the Cron Job send an Email to local host for Root. Otherwise it will just show up in the logs after done.

Really you do not need to be notified when the task is done. You need to be notified when it fails or did not complete because of an error.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: notification when task is done

Mon Jul 11, 2016 4:33 am

broe23 wrote:You are not using the terminal when uploading something, by using a Cronjob or such.
Actually you may be surprised. There's quite a number of CLI File Transfer Protocols, like FTP, sFTP, SCP, rsync or even the old xmodem, although I think only us old router jocks still use that one flashing old Cisco equipment. But use what you have.
Really you do not need to be notified when the task is done. You need to be notified when it fails or did not complete because of an error.
That's kind of up to the OP, since they asked to how to be notified when the jobs completed and all.
Account Inactive

W. H. Heydt
Posts: 14048
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: notification when task is done

Mon Jul 11, 2016 4:53 am

SonOfAMotherlessGoat wrote: Actually you may be surprised. There's quite a number of CLI File Transfer Protocols, like FTP, sFTP, SCP, rsync or even the old xmodem, although I think only us old router jocks still use that one flashing old Cisco equipment. But use what you have.
Pscp, kermit....

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: notification when task is done

Mon Jul 11, 2016 9:41 am

W. H. Heydt wrote:Pscp, kermit....
Zmodem was always my favorite. And yeah, don't tell the OP that he doesn't want to do something that he very likely does want to do. In the old days, we often put an echo statement with a bunch of bells at the end of a script for something like this.

User avatar
Pilosopong Tasyo
Posts: 116
Joined: Wed Apr 06, 2016 11:43 am
Location: /root

Re: notification when task is done

Mon Jul 11, 2016 10:21 am

pyraylos wrote:hi. i often upload files from my rpi2 to the cloud through terminal and it takes a long time. is there a way to get a notification(to my mac) when the task is done?
On the Pi itself, it's easy. You can either have a visual or audio notification. The tools necessary to make it work are already installed. Sending a notification to a Mac involves a bit more work AFAIK. If you can SSH to your Mac from the Pi, and your Mac has the same or equivalent/similar CLI tools to make visual or audio notifications, it can be done. (Don't ask me what or how to use those equivalent MacOS tools are, as I have absolutely zero experience using a Mac.)
Give a man a ghoti and he'll eat for a day; teach him how to ghoti and he'll eat for life. Ghoti?! - http://i.imgur.com/mAfBUdi.png
How To Ask Questions The Smart Way - http://www.catb.org/esr/faqs/smart-questions.html

epoch1970
Posts: 5914
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: notification when task is done

Mon Jul 11, 2016 10:52 am

I wonder if https://github.com/jpmens/mqttwarn isn't part of the answer?
I meant to look into it but that's still on my TODO list...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

pyraylos
Posts: 6
Joined: Thu Feb 11, 2016 4:42 pm

Re: notification when task is done

Mon Jul 11, 2016 2:46 pm

Pilosopong Tasyo wrote:If you can SSH to your Mac from the Pi, and your Mac has the same or equivalent/similar CLI tools to make visual or audio notifications, it can be done.
can you tell me how to do that on linux instead of mac?

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: notification when task is done

Mon Jul 11, 2016 8:27 pm

Mac OS-X runs on a derivative of BSD. Pretty much anything you can do in Linux, you can do in OS-X.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

User avatar
Pilosopong Tasyo
Posts: 116
Joined: Wed Apr 06, 2016 11:43 am
Location: /root

Re: notification when task is done

Tue Jul 12, 2016 1:55 am

pyraylos wrote:
Pilosopong Tasyo wrote:If you can SSH to your Mac from the Pi, and your Mac has the same or equivalent/similar CLI tools to make visual or audio notifications, it can be done.
can you tell me how to do that on linux instead of mac?
When you...
pyraylos wrote:...upload files from my rpi2 to the cloud through terminal...
in what manner do you do it? Do you have a KB/M+monitor attached to the Pi2, have a full desktop running and you upload files from the Pi desktop itself? Or does the Pi2 run headless and you use your Mac to remotely connect to the Pi2 via SSH and upload files that way?

Giving us relevant details on how you do things on your end gives us a better idea how to approach your problem.
Give a man a ghoti and he'll eat for a day; teach him how to ghoti and he'll eat for life. Ghoti?! - http://i.imgur.com/mAfBUdi.png
How To Ask Questions The Smart Way - http://www.catb.org/esr/faqs/smart-questions.html

pyraylos
Posts: 6
Joined: Thu Feb 11, 2016 4:42 pm

Re: notification when task is done

Tue Jul 12, 2016 3:39 pm

the rpi2 runs headless and i use my mac to connect via ssh.

User avatar
bensimmo
Posts: 5058
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: notification when task is done

Tue Jul 12, 2016 3:46 pm

I will ask, how do you/what do you do to upload to whatever cloud.
As mentioned up there, there are plenty of file transfer protocols, or maybe this is to OneDrive/DropBox/MacEquivCloud style cloud storage?

Would an email suffice?

jayminer
Posts: 44
Joined: Sun Jul 07, 2013 3:33 pm

Re: notification when task is done

Tue Jul 12, 2016 7:03 pm

If you're connecting to the pi from the terminal on the mac and just run a simple command, you could do something like:

ssh raspberrypi2 scp filename cloud: ; <mac notification command here>

This will simply log you in via ssh, run the command - and when it's done, run whatever you type after the semicolon on the mac. I remember growl having a simple command-line-notification-command but I haven't used that in ages.

User avatar
Pilosopong Tasyo
Posts: 116
Joined: Wed Apr 06, 2016 11:43 am
Location: /root

Re: notification when task is done

Wed Jul 13, 2016 5:32 am

jayminer wrote:<mac notification command here>
The OP can do a search in his favorite search site for the following terms:
a. for visual cue - mac osx equivalent to zenity
b. for audio cue - mac osx equivalent to aplay
Give a man a ghoti and he'll eat for a day; teach him how to ghoti and he'll eat for life. Ghoti?! - http://i.imgur.com/mAfBUdi.png
How To Ask Questions The Smart Way - http://www.catb.org/esr/faqs/smart-questions.html

Return to “General discussion”