Restart/shutdown mac remotely from iOS through SSH? - objective-c

I set up my old laptop as a media server and created a mac application in AppleScript that would remotely restart or shutdown the mac depending on which button was pressed, using this code:
tell application "Finder" of machine "eppc://USERNAME:PASSWORD#MYSERVER"
shut down
end tell
It's super simple, and was easy to write, but now I want to create an iPad app that can accompany the mac one. Ideally, I'd like to use AppleScript as, like I said, it's very simple, but I feel like that's not an option.
What are some other ways to do this? Where I would click a button, then it would connect to my mac and either shutdown or restart.
I feel like the best way would be to use SSH, and right now I'm looking at https://github.com/x2on/libssh2-for-iOS. Any other ideas?

Okay, just to brainstorm.... Dropbox is a great way to share content among machines, but it's also a pretty darn decent communication mechanism.
I use Dropbox to fire up (legal only!) bittorrent downloads on my home machine by setting up my torrent client to watch a dropbox folder for incoming .torrent files. I can then save .torrents into that directory on any machine I have Dropbox on, or in principle from a browser on my iOS devices that could share to Dropbox, and ta-da, instant remote kickoff. I can sit on another machine, save a .torrent to that directory, watch its file extension change to .torrent.imported, and know that when I get back to my main machine, that thing will be downloaded.
You could use folder actions or a cron job to watch a certain Dropbox folder for commands, and then put files into that folder that trigger those scripts to perform certain behaviors. Dropbox has a very nice iOS client library, making it totally possible to store stuff to Dropbox from a custom app.

Related

WP push files to device over company app

With a company App configured on a Windows phone there is the posibiltiy to push the installation of an App. When the user starts the pushed App some configuration data must be introduced. I would like to save the user this step but I still don't know how. Isn't it possible to push files over the company App/Exchange, as it is on a Windows machine? So I could read the configuration out of this file.
your use case does raise many questions (probably just terminology)
The only way to push an APP to a device is through the Windows Phone store or website.
If you want to push configuration to a device for an app then the app must be run at least once to enable that ability and you could then use a background task to periodically check for new configuration and download it.
The other thing you can investigate is push notifications but they are not really meant for pushing data, you can sent simple objects or data to the device as a raw push but the app must be running first.
The most common way to achieve what you describe is to have the app load config at launch, locally first and then update it from a web call (if web is available, as these are mobile devices you can not guarantee connectivity). We do something very similar with AdRotator where we try to download config at start and if that fails use a locally cached version.
As of WP 8.0 there isn't the possibility to push Apps or Files through the company App.

Monitor changes made by a desktop app to a file created by my Windows Store app

I'm making a Windows Store app that gets files from a server and store it locally for quick access. I also want to make it sync the file with Dropbox and push changes to Dropbox if the user make any. I looked into CachedFileUpdater and it seems to work if I use another Windows Store app to edit the file. However I ran into a great trouble trying to monitor changes made by a desktop app. This matters a lot because many files are office documents and Office 2013 is available to Windows RT and I would also like the app to be available to Windows 8.
First I tried to use CachedFileUpdater on all files but when I open the file using a desktop app, it will be opened in read-only mode and I can't save it in desktop mode. If I dont use it if the user chooses to open it with desktop app, the change will be saved but later my app won't be able to access that file somehow. I guess it is because the owner changes to the desktop app. Now not only I seem to have no way to monitor the file changes, but also can't I access those changes once it is modified by a desktop app.\
Is there some trick that may help? Thank you very much!

Automatic file selection for upload

Is it possible for a website to automatically find a folder on usb stick and upload all the files in it to the web server by clicking only one button?
The problem is that I don't know how to make upload form automatically detect usb stick as the drive name(ie. G:, F:, etc) may vary from computer to computer, so hard coding path is not possible.
Ps. I'm using yii framework for site development, but can add a new page that will handle this in any other language as the client really wants this feature.
Web sites are not allowed to set default files to upload (it's a major security risk!). Also, web sites cannot scan the hard drive/enumerate what file systems exist on a system, again, for security purposes.
It might be possibly to do this with Flash/Silverlight/Java. Java seems the most likely to allow a web developer to do this (Java plugin seems to be quite willing to give out every permission under the Sun).
Short answer: No.
Long answer: Allowing automatic uploads in web browsers would be a huge security hole so the browsers intentionally prevent it. Even if you manage to find a hole that permits it, the browser makers will break it as soon as they find out.
However, if you have an environment where an actual separate program can be installed on the end user's computer you could easily write a program to do automated uploads of specified directories when launched.

How to get started writing desktop application for OS X that manages a directory in the background?

I want to create a desktop application for OS X that does 3 things:
Creates a directory on the users computer with a custom icon
Downloads files to that directory from my server
Monitors changes in that directory and subdirecties so that it may send commands to my server
I understand how to download a file into a directory and communicate with my server. Where I lack knowledge is really the steps to get started so that the app is essentially this "smart sync folder."
Can anyone recommend tutorials, sample code, or just some general direction of how to get started on an app like this? Think really stripped down version of DropBox
Well, since you already know how to handle the web stuff, next step would be to get notifications when your folder changes.
Here's a good discussion of some good approaches (somewhat dated)
or
Download this demo to get started

Making an application launcher

Okay so I want to make an application that launches other applications. However, the goal here is to make the app "portable" in that I can go from one windows desktop to another while using the same application from a usb drive. So here is a different rundown of what I mean:
I have aplication X. I use it on machine 1 and I want to use it on machine 2. However, machine 2 is my buddy's and he does not want me installing things on it. So, I take all the files that the installer made on my system, and put them into folders. App X put files in the windows folder that it expects when it is launched. If I merely run the the app and it looks in the windows dir it will not find the files. I do not have/want the ability to put files in the windows dir. I want to tell the app to look in folder a for files in folder b instead of where it would normally look. I could then use this program on any machine without having to modify the machine in any way.
Is this doable? If so what is it called so I can look it up?
EDIT: the win dir was an example. I would like the app to be self contained in a folder on the thumb drive. I want to redirect the where the app looks for files to a folder I specify.
This can be done, but how easily depends entirely on the program that you are launching.
The sorts of things that applications will do are:
Just run happily being executed anywhere (no dependencies). These are very easy!
Require some environment variables to be set up. This is easy to do - you can launch a new process with a modified environment if you wish.
Read files from disk. Usually when loading things like .dlls, applications will search on the PATH for the dlls, so they can be copied into the application folder (next to the .exe) and it will run happily on any system. However, in some cases applications will use fixed (or at least, less flexible) paths so that they will be harder to launch successfully.
Read registry settings. This is trickier. You need to know what state is required by the application, have your launcher record the old registry state, change it and run the application, then wait for application exit to restore the original state. This has to be bullet-proof to avoid corruption of the user's registry.
Ultimately you'll need to investigate, for each app you want to launch, just what it needs to run.
If the apps are commercial, then be careful that you are not breaking any licensing (EULA) terms by running them in this way.
Another alternative would be to set up a virtual PC image and simply execute that on the host PC so there is no need to worry about any special cases for each application. Depending on the VPC software you have available you may need to install software on the host PC to allow a virtual PC session to be run though, which may defeat the purpose/intent.
I think the system you describe is U3 (more info at http://en.wikipedia.org/wiki/U3). It requires the application to follow the U3 protocol, but if the application does, then it can be run off of a U3 flash drive without any install or admin permissions required on the host machine.
It's a proprietary technology, and supported by only a few vendors that I've seen.
If you really want portability and power, consider VMWare Player, and carry and entire machine, customized to your needs, on the flash drive. Of course, your friend would probably have to allow you to install VMWare Player.