How do I grant a cron job webcam access in Mac OSX Mojave? - cron

In OSX Mojave, access to the camera is controlled by pop-up dialogs and the new System Preferences>>Security & Privacy>>Privacy>>camera panel, where apps can be granted (or denied) access to the camera.
I can grant "iterm2" access to the camera, which lets me run imagesnap from the commandline.
I use a cron job to capture a photograph of the cat bed every 60 seconds. This now fails, since upgrade to Mojave, because it does not have permission to access the camera. Is there any way I can give my cron job access? I don't get a pop-up dialog for a cron job.

Using an Automator application wrapper also works. Create the wrapper (run shell script), run in manually and grant it permission. Then the cron job can call the Automator app.

I hacked around this by using a wrapper script that indirects through Applescript to use iTerm, which does have permission, and have cron launch the wrapper.
#!/bin/bash
osascript << EOF 2>&1 | grep -v "window id"
tell application "iTerm"
create window with default profile command "/path/to/capturescript"
end tell
EOF

FWIW - Mojave broke this further, and the Automator app broke.
I lost a lot of time fiddling with it, and then gave up. It seems the security of camera devices changed again. My time is expensive and raspberry pis are cheap; I connected the camera to a pi and now access it from cron with "ssh pi fswebcam - > output.jpg" which works flawlessly.

Open Automator on Mac.
Click New Document.
Choose Application.
In search bar search for Run Shell Script and add to application with click.
Add code for running your desired script (like you would run the script from shell).
On top right click Run.
Allow access to camera.
With installed cronjob you should be fine.

Related

Need to schedule Cygwin Expect Script with Windows Task Scheduler

I am currently in the process of implementing a backup scheme to run a Cygwin Expect Script. What I would like to do is have task scheduler open Cygwin and run an expect script called Backups.
The issue that I run into is what I believe to be either variable or path based. I have the correct user from Active directory (we'll call it AD/svc_backup) set, and I am currently trying to just see if I can get the task scheduler to open Cygwin.
So far it will only open the program if I have the run only when user is logged on radio button pressed. This will open cygwin, but not let me run any further commands and gives me an error.
For example ls gives me "bash: ls: command not found" When it asks what program I want to start, I simply point it to the shortcut on my desktop and it then fills in the path C:\cygwin\bin\mintty.exe . Task scheduler does not seem like the most intuitive tool IMO but if I can get it to work I will use it. I also know that cygwin can use cron as well. Would cron be a better option?
I figured it out. So what the system means by the button "run only when user is logged on" radio button pressed" means is I want the script to run and I want to see it run with the local usr account. (interactive with the user)
The "run whether the user is logged in or not" button turns whatever script or program you run into a background service that has no user interactivity( you cant see it). By using the full path under the actions tab in cygwin I was able to tell it which script to run. Script path and options are like so:
C:\cygwin\bin\bash.exe -l -c C:/cygwin/home/svc_p_cisco_bkp/
I have been researching the -l and -c arguments and from what I can gather the -l means list the output and the -c means run these commands. This was not listed anywhere but from what I read it is as educated of an answer as I can give. Also I tested and the script will not run correctly without these variables.
I don't see the script start when I check the "run whether the user is logged in or not" button, but I can see the backups going to my destination folder. I do see it when "run only when user is logged on" however. What I did was get the script running the way I wanted while I could see it and then choose the "run whether the user is logged in or not" radio button when I know it was working correctly.
All is up and running and after exhausting reading of pages and pages about Windows task scheduler, and I am fully automated.

How to automatically start and advance a few steps in an application in background in linux?

I'm using Genymotion to run WhatsApp on Ubuntu 13.04 as I don't own an Android.
To get to Whatsapp everytime I login, I have to
1) open terminal and run ~genymotion/genymotion
2) click a button on the GUI which opens up another new window (play button).
3) wait for about 30s for the device to get ready.
How can I make the computer do these first two steps automatically for me at start up?
Even better if it possible to do them in background, i.e., I shouldn't see the GUI opening. It should perform the steps and be "minimized".
I was thinking if there was a way to record what my click does and then put it in a script.
Something like a strace command.
I hope my question is clear enough. I'm relatively new to Linux.
For now Genymotion allows you to start a VM from the command line, by calling the "player" binary, and passing the VM name as a parameter.
You could write a shell script that:
run: <GENYMOTION PATH>/player --vm-name <VM NAME>,
wait some seconds for the VM to boot: sleep 10,
then use adb to start your Application: adb shell am start -n com.whatsapp/com.whatsapp.Main
Luckily, no need to simulate clicks for this.

Linux - Make Application started in a terminal launch on a different display

I have inherited an application that is launched at login time from my server's .bashrc. The application starts two gnome-terminals. If I am logged in with a gnome desktop, it works great. Two terminals open on the desktop.
Sometimes I kill the application and must restart it. Works great if I launch it by hand from a terminal on the desktop (causing me to have 3 terminals open).
However, if I telnet into the machine where the application is installed, as .bashrc executes I get all sorts of "cannot open display" errors.
Well, of course I can't, I'm not logged in from a gui interface, But a desktop IS running on my server and is logged in using the same ID! Why not put the terminals there?
So how do I say, in bash, "start this application and send its output to 1) the display where you are now, or, 2) the one currently up on the server?" (I assume that found by looking at the env var display?)
Ubuntu 10.04 64 bits. I telnet to the server to start the vncserver so I can access the aforementioned desktop.
Thanks,
It depends on the application exactly, but generally you simply export the DISPLAY environment variable and the application should start on the specified display.
eg:
export DISPLAY=localhost:0.1
xterm &
Some applications would also (or alternatively) take a --display command line argument - check into the specific options available for the applications you're using.

Screen process hangs in cygwin

I'm trying to run screen (version 4.0) in the latest version of Cygwin under 64-bit Windows Ultimate, and it doesn't want to work. I launch a new screen session using "screen -d -m -S screen1". When I connect to it using something like "screen -A -d -r screen1" the process hangs. When I list screens with "screen -list" it reports the screen as "possibly Dead".
Any idea how to get screen working in my environment?
I just ran the same commands you did, and had similar problems. But I use screen under 64-bit Windows 7 all the time.
I just use screen to start a screen session, and screen -dr to reattach to the same session later. (I've actually been using screen -U and screen -drU, but I just realized that with defutf8 on in my $HOME/.screenrc, the -U isn't necessary.)
I haven't figured out why your approach doesn't work.
I am also currently trying to get screen work on a cygwin installation on a windows server 2008 installation.
it works in principle, so I can reuse sessions, but its quite buggy:
1.) only sessions started through an rdp session (on the windows desktop) are able to access mounted network shares, sessions started through ssh can only access "c". (okey not really a screen bug, more cygwin in general)
2.) detach doesn't work through ssh. strg+a+d just freezes the terminal, by using these keys in that sequence: [strg+z, bg, %, strg+c] I can get back into the screen session I've last visited.
3.) this leads to the funny state that I can have the same screen session attached multiple times, and see the input and output on all instances

Setting Programs on Redhat5 Startup

I have a Redhat 5 OS, a dual monitor setup, and two workspace. When the machine reboots, I want to set the following:
On workspace 1,
* run the thunderbird-client on the left monitor.
* run 3 terminal clients on the right monitor.
On workspace 2,
* run firefox on the right monitor.
Can someone point me as to where I can set these settings? I am sure there is a way since when my machine boots up, couple of terminal clients pops up, my irc chat client pops up as well. I do not know how I did this before.
You could try Devil's Pie (yum install devilspie)
It's a tool for creating rules that will bind specific actions to applications as they are launched (i.e. setting workspace, position, transparency, etc...).
I found some doc here: http://www.foosel.org/linux/devilspie and here: http://live.gnome.org/DevilsPie
Of course, saving your workspace on logout can help too (System > Preferences > More Preferences > Sessions, then check "Automatically save changes to session").
Once you have setup your application rules, you could write a simple Bash script to start them all in sequence, and add that script to the Startup programs in the sessions preferences.

Resources