Mac OS X -- lost all app in Application folder - macos

I have a big issue.
I type this command in Terminal app
bless --folder /Volumes/Applicaitons --openfolder /Volumes/DIRECTORY
After that, all app in Applications disappear. I don't why how to backup all.
Please help me.

Wow. That looks like a potentially massive mess you've made. Hopefully you haven't attempted to reboot your machine.
Try doing:
bless --folder /System --openfolder /
and that should reset your blessed folder.
If the Applications folder stays invisible, you can make it visible via:
SetFile -a v /Applications
(by the way, is "/Volumes/Applications -- the name you typed in a panic up in your question -- a valid hard drive volume?? or did you mean "/Applications"?)

Related

How do I present application with additional server mode on macOS to customer

I have a desktop application that I successfully package and install on macOS using dmgcanvas. The user simply drags the icon into Applications to install and then run by clicking on the Application Icon in Applications.
My problem is whereas the software was previously a Desktop only application it now has a new mode whereby it runs as a server, and can then be controlled via a web browser. On Windows, I would simply create another .exe file with the option set to run as server and put this in the installation folder, so the user would just run MyApp.exe or MyAppServer.exe
But in macOS I can not see how to do the equivalent thing since there is just one folder Myapp.app containing the installation and clicking on Myapp.app runs the application, so where do I put MyAppServer?
Of course, the user could right-click on MyApp.app and run Show Package Contents and then navigate to a subfolder such as bin containing a cmdline version that runs in server mode. But how is the user supposed to know how to do that, I want an easy way for the user to run MyAppServer?
Its hard for find documentation of how things exactly work on MacOS. But below is a good article
https://mathiasbynens.be/notes/shell-script-mac-apps
The internal folder structure may vary between apps, but you can be sure that every Mac app will have a Contents folder with a MacOS subfolder in it. Inside the MacOS directory, there’s an extension-less file with the exact same name as the app itself. This file can be anything really, but in its simplest form it’s a shell script. As it turns out, this folder/file structure is all it takes to create a functional app!
They have a simple script to automate the whole process
#!/usr/bin/env bash
APPNAME=${2:-$(basename "${1}" '.sh')};
DIR="${APPNAME}.app/Contents/MacOS";
if [ -a "${APPNAME}.app" ]; then
echo "${PWD}/${APPNAME}.app already exists :(";
exit 1;
fi;
mkdir -p "${DIR}";
cp "${1}" "${DIR}/${APPNAME}";
chmod +x "${DIR}/${APPNAME}";
echo "${PWD}/$APPNAME.app";
So what I would do is that, instead of having my apps binary directly, I will have a Shell Script and the Binary in the same folder. This shell script will check if the AppName Server.app already exists or not, if not, it will create the folder and put a script which then calls your original app with -r flag.
And then I would just run the actual app with the pass arguments that were passed to the script
Is this the best approach? Not sure about that, I could not find a way where a app has multiple Icons in but just one folder. In this case the Server option will not exists on first installation of the app, but after the first run of the app. You could even ask the user if they really want an additional icon for the app or not.

Run my Mac command "chsh -s /usr/local/bin/false" and can't log in to my account again

I really messed up!
Since I ran my Mac with the command below
chsh -s /usr/local/bin/false
Several minutes later, I noticed my Mac logged out by itself.
So, I tried to log back in by clicking 'change user'
But I can't see my administer account there.
I guess 'false' is not a loggin-able shell, that's why my account is hidden.
I'm trying to change my shell with Terminal.app on recovery mode or single-user-mode (but both are read-only).
So right now, I want to know if there's any solutions that might be able to fix this problem.

case sensitivity when running OS X app from terminal

i've noticed that when i run application from the terminal stating its direct path, it depends on case sensitivity. i've found out that when MacOS is written in lower case, it fails to run due to lack plist file, as can bee seen below :
[13:37 zzz ~/ ] /Applications/Notes.app/Contents/macos/notes
2015-07-23 13:37:34.924 notes[1205:12990] No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting
whereas the correct case manage to run the application.
[13:37 zzz ~/ ]$ /Applications/Notes.app/Contents/MacOS/notes
can you tell me what is the reason for this behavior ?
thanks
Actually, this is a consequence of the formatting of the hard drive you're using.
If your hard drive (or SSD) had "case-sensitive" formatting, that's why you need to be explicit about MacOS instead of macos.
If you had formatted your hard drive for simply "Journaled", then you could get away with using all caps.
More information can be found here and here.

Appearance of a tilde(~) in mac OSX terminal in the path

I am new to the Mac OSX environment, and was programming in C using the terminal. To change the current directory, I used the command cd .. to go one level up. However, this had a weird effect on the terminal. A clear screen on my mac terminal normally used to show this path always-
manishs-mbp:manishgiri$
However, since the time I did cd .. (to go one level up), the current pathway of the terminal has changed to:
manishs-mbp:~ manishgiri$
As you can see, there is a tilde now in the pathname. On reading about it, it looks like this tilde is used to represent the home directory in mac os. However, i would like to get rid of it, as it was earlier.
I tried to think of it, and realized that cd .. would have taken me one level up. So, I entered pwd in the terminal to see the current pathway(this is with the tilde situation), and got this-
manishs-mbp:~ manishgiri$ pwd
/Users/manishgiri
Maybe the tilde appears because I am now by default in the /Users(Home) folder. If that's the case, then how do I revert it back to the previous settings to get rid of the tilde?
Any help on this would be highly appreciated, thank you.
Try
PS1=`pwd `
to set your prompt.
If you like that, check in your home directory for a file called .profile and edit PS1 setting permanently into there.
This may help.

Applescript application hangs on 10.9 when executing a shell command with administrator privileges

I'm executing the following line in an Applescript application.
set POSIX_path to "/Applications/iPhoto.app"
do shell script "sudo rm -rfv " & quoted form of POSIX_path with administrator privileges
The authentification screen pops up as it should but after authenticating the application just freezes upon executing this command. This problems only occurs in 10.9.
When I set the permissions of the folder to be delete to "everyone can read & write" it works.
Does anyone have a clue what has been changed?
EDIT: When I repeat the execution of this script by checking du -shx /Applications/iMovie.app it manages to delete a few more files with every try.
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.4G /Applications/iMovie.app
-- force quit AppleScript --
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.3G /Applications/iMovie.app
-- force quit AppleScript --
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.0G /Applications/iMovie.app
Its working fine on OS X 10.9 (13A603)
set POSIX_path to "/Users/paragbafna/Desktop/untitled folder"
do shell script "sudo rm -rfv " & quoted form of POSIX_path with administrator privileges
Does anyone have a clue what has been changed?
Well yes.. Gatekeeper has changed, that may be the cause..
When I set the permissions of the folder to be delete to "everyone can read & write" it works.
Did you do this from Finder or from the command line with chmod 0777? The latter may delete some attributes that Finder does not remove.
What setting is selected here, on your computer?
If you have a restrictive setting, try "Anywhere" to see if it solves the problem. If this is the cause you may:
Have custom command line tools installed, (e.g. MacPorts) or something you compiled yourself (since this is happening on 3 but not all computers and obviously you are not a "generic" user).
Your applescript is not being trusted, you can try signing it if possible, otherwise this may work:
If the user wants to run an application blocked by Gatekeeper, they have several options. Gatekeeper could, in effect, be turned off by letting it run all applications. A power user may opt to remove the quarantine attribute or use the spctl command to add a new policy in the security assessment policy subsystem. - TrendMicro - about Gatekeeper
Last resort idea.. Check your disk permissions, re-install Xcode if you use that, maybe the signatures are corrupted.
Write a shell script instead, I don't know if it is just about deleting a few files, then you can definitely do it in shell script, or comment to let me know what you're trying to achieve.
After days of trying everything to sort out this problem I finally found what was causing this issue.
It's the verbose-option (-v) of the rm-command. Leaving it out makes the application work flawless again.
Maybe Apple accidently introduced a buffer overflow. I will report this under the problem ID 15309626 I created at Apple's bugtracker. Maybe they'll fix it until the first 10.10 DP :D

Resources