Can't Copy folder to specific location using terminal - Mac - macos

I could not find a usable solution to this seemingly simple problem, despite my best efforts.
I'm using MacOS High Sierra 10.13.6
I have a folder I want to copy with the following location:
/Users/ep9k/Desktop/Key-LogEcovaluator/whereami
I want to copy it to this directory using the terminal:
/Users/ep9k/Library/Application/Support/QGIS/QGIS3/profiles/default/python/plugins
I tried the following commands in the terminal. Notice I am in the 'whereami' folder when doing this:
whereami ep9k$ cp -r /Users/ep9k/Desktop/Key-LogEcovaluator/whereami /Users/ep9k/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
whereami ep9k$ cp -a /Users/ep9k/Desktop/Key-LogEcovaluator/whereami /Users/ep9k/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
I'm met with the following message indicating I am not using it correctly:
However, I created a "tester" folder on my desktop and can copy to this folder with no problems, using exactly the same command (except with the pathname changed to my tester folder).
I can also copy and paste things to this directory using the GUI "finder". What am I missing?

Your destination path contains at least one whitespace character ("Application Support"), which causes the "cp" command to think it's being given three arguments instead of two. Enclose the destination path in single or double quotes and you should be all right.

Related

Windows Jenkins How do i use WORKSPACE system parameter when it has spaces?

I'm using Jenkins over windows 7 and i encountered strange behavior.
when im trying to copy files to working directory - represented in Jenkins by the system parameter WORKSPACE, for example like in this code:
cp -a hpdevops-discovery-demoapp-master/. $WORKSPACE/
i get the following:
cp -a hpdevops-discovery-demoapp-master/. 'C:\Program' Files '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/'
cp: target '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/' is not a directory
what's happening: the workspace located here: C:\Program' Files '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/
but, because of the space in the path after the word 'Files' its deviding it into 2 and treating the second part - which is just half of the path, as the target path: '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/'
i used to work with Jenkins on Linux and never had a problem like this when using the WORKSPACE system parameter.
anyone run into this?
use double quote wrap it like "$WORKSPACE"

How to change $PATH variable in bash_profile in OSX?

I am trying to install a 3rd party library from GitHub through terminal. Before this installed Anaconda Python distribution on my system and that has modified my root directory of my terminal to;
Vinos-MBP:~ Vino$
So when try to navigate to a particular directory to install the said library using
cd /Users/Vino/<install location>
The terminal prints the following message;
-bash: cd: /Users/Vino/Documents/My: No such file or directory
I know this problem is because Python has modified my bash_profile startup file. I tried various online methods to fix this issue, but nothing actually works. Whenever I restart my terminal and navigate using cd, I get the same error. How do I reset $PATH to $HOME (like as before installing Anaconda), so that I can navigate to any folder on my system?
This is not a problem with $PATH or $HOME -- it looks to me like you have a space in the folder name, and aren't properly quoting/escaping it. If they aren't quoted or escaped, spaces are taken as separators between arguments (e.g. folder paths) rather than part of the path. If the folder you're trying to cd to is "/Users/Vino/Documents/My Installation Location", you could use any of these:
cd "/Users/Vino/Documents/My Installation Location"
cd '/Users/Vino/Documents/My Installation Location'
cd /Users/Vino/Documents/My\ Installation\ Location
cd ~/Documents/My\ Installation\ Location
cd ~/"Documents/My Installation Location" # Note that the ~/ part must not be quoted
There are a number of other characters that're perfectly legal to have in filenames that will cause trouble when used on the command line without quotes or escapes (including the quote and escape characters themselves!). One way to avoid trouble is to drag-and-drop an item from the Finder into the Terminal window, and it'll fill in a (properly escaped) path to that item.

MacOS Terminal go to a folder with spaces and parenthesis

I'm trying to configure Cyberduck to read the Bookmark files from my Dropbox folder.
This is usually accomplished by this command:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck
Super easy!!
But... Dropbox has since changed and if you have a Pro Account the Dropbox folder is renamed "Dropbox (Personal)".
I've tried to do this:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox\ \(Personal\)/
And I get this error:
not parse: [...]/Dropbox (Personal)/Apps/Cyberduck/. Try single-quoting it.
I tried single quoting like this but same error:
defaults write ch.sudo.cyberduck application.support.path '~/Dropbox\ \(Personal\)/'
How can I solve this?
You can single quote escape your parentheses by wrapping them in a double quote:
Instead of: ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName
Do: ln -s "'/Users/username/Dropbox (Company Name)/'" DropboxCompanyName
Notice the double quotes added to /Users/username/Dropbox (Company Name)/
So I cannot find a way to do a "defaults write" to a path with parentheses, but I did this workaround and it seemed to work for me (in my case I needed to link to my enterprise Dropbox account):
cd to your home folder and create a symlink of the directory that has the parentheses:
ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName
At that point, I was able to do do a defaults write that wrote ~/DropboxCompanyName as part of the path and it worked just fine.
All that said, your personal folder already has a hidden symlink: "Dropbox" that's in the same directory and pointing to "Dropbox (Personal)", so you should be able to do you original command as such:
defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck
… because the "Dropbox" part of the path should still lead to your personal folder. This both what I've observed locally (when viewing hidden files) and what Dropbox says on their site: https://www.dropbox.com/help/9031
I am assuming you are using Unix in Terminal.
I have set up a folder of the same name in my Public Folder to test as shown below.
Your current referencing to the folder would seem correct. Dragging the folder into the Terminal window current command line will automatically give you the correct referencing to that folder.
As an alternative I suggest putting the name of the folder in double quotation marks. Even though there are brackets in the name, there is no need to escape these characters in Unix in Terminal in this instance when using double quotation marks. This makes it easier to humanly type the correct reference.
To reference a folder in the image below, for example, the following referencing works for the cd (change directory command):
~/Public/"Dropbox (Personal)"
Hence I suggest try:
ch.sudo.cyberduck application.support.path ~/Public/"Dropbox (Personal)"
As for the rest of this command, I am not sure that ch is a valid Unix command. I do not yet have enough Unix experience to guide you from here.
you have to put "" in the whole address
more like this
ch.sudo.cyberduck application.support.path "~/Public/Dropbox (Personal)"

rsync with AppleScript, copy from other volume

I'm trying to build a automatic backup solution. My AppleScript commands are pretty simple. All I want to do is copy all the files in one folder to a different folder.
Currently I'm using this:
rsync --update -raz --progress Documents/test "Volumes/RFM_Projects_2"
This works when I have my files located in a folder called test in the Documents folder. Problem is that I have a different folder structure now where I have all the files I want to copy on a second internal harddrive.
I thought it would be easy to just change "Documents/test" to something like "Volumes/WORK/test", but this does not work at all.
Any ideas about how I can change the source location to a secondary harddrive?
All slash-delimited style paths, like the ones used in your rsync command, must start with a slash (/). That slash stands for the startup volume drive. I do not see that first slash in any of your paths so I'm surprised any of your code ever worked. Here's an applescript which will show you the path. Run this, select any folder you want, and copy/paste the result into your code. Note that if there are any spaces in any of your paths then you should put your paths in quotes in your rsync command.
choose folder
return POSIX path of result
Also note if you want the path to a file instead of a folder then change the word folder to file in the applescript. Good luck.

How to change the copy file behavior in mac osx

I used to use Ubuntu
most of time, the command are same as Ubuntu
But there is a command annoys me.
it is cp (copy command)
because I often type cp -a FOLDER/ target
to copy a file , however , the command will copy all the folder under FOLDER/ but not including FOLDER/ itself.
I know I can get what I want by using cp -a FOLDER target (without the slash in the tail)
it easily to misuse the command.
Is there any way to change the behavior, thanks
The command cp is a program in /bin so you could rename the cp command to another file, such as main_cp.exe and create a batch file (script) of your own called cp, which changes the call from what you type to what is actually required and then calls main_cp.exe.
However, if you're going to be using OSX a lot and perhaps on other people's machines, learning to train yourself to just not type the slash is probably going to be better in the long term.

Resources