running rsync in cygwin - powershell

I am trying to run rsync from cygwin in a PowerShell script of a remote folder with having space (File - One) and gets the below error. Tried to escape the space but still it does not work. As in the error, the directory name taken is "/e/Files/File" which is incomplete, whereas the actual folder name should be "/e/Files/File - One/root/" . Also tried the escape the space with multiple backslashes but still same error. What could be issue here?
Write-Output $rsync-cmd
Invoke-Expression -command $rsync_cmd
Command and Error:
C:\cygwin64\bin\bash.exe --login -c 'rsync -tvhPrI --stats jason#10.1.1.100:"/e/Files/File\ -\ One/root/" "/e/Files/File\ -\ One/root"'
receiving incremental file list
rsync: link_stat "/e/Files/File" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1637) [Receiver=3.1.1]

I've just been wrestling with this and all problems solved by running my script through dos2unix to remove rogue ^M

Related

Postgresql copy command not finding file

when running:
~/fidelity/releases/20220907033831$ ls -a
.
..
.browserslistrc
221005_users_all.csv
_private
the presence of a file is confirmed.
However, when launching a postgresql command
psql fidelity_development
COPY users (id,migrated_id,[...]) FROM '~/fidelity/releases/20220907033831/221005_users_all.csv' DELIMITER ';' CSV HEADER;
The response is unexpected:
ERROR: could not open file "~/fidelity/releases/20220907033831/221005_users_all.csv" for reading: No such file or directory
What am I missing to determine why postgresql cannot see this file?
note this directory was also simlinked as fidelity/current and the same result was obtained when referring to that directory for the file, whereas bash sees it.
Use \COPY command as this one is client based and handles the local path correctly.
While COPY is server based and this could cause issues finding your file.

Autorunsc64 (sysinternals) command line issue in PowerShell

I am trying to execute autorunsc64.exe (Sysinternals) in PowerShell like so:
"C:\Program Files (x86)\Autoruns\autorunsc64.exe" -a * > "C:\Program Files (x86)\Autoruns\output.txt"
However, it does not like single or double quotes anywhere. I've tried many variations but cannot seem to find the solution. I keep getting the following errors:
Unexpected token '-accepteula' in expression or statement
Unexpected token '-a' in expression or statement
If the paths do not have spaces, it works without issue:
C:\Temp\Autoruns\autorunsc64.exe -accepteula -a * > C:\Temp\Autoruns\output.txt
How can I type this up to work with C:\Program Files (x86)\Autoruns\autorunsc64.exe -a * > C:\Program Files (x86)\Autoruns\output.txt so it can run from these locations using PowerShell?
Very common question.
& "C:\Program Files (x86)\Autoruns\autorunsc64.exe"
Or even
C":\Program Files (x86)\Autoruns\autorunsc64.exe"
I would just add it to the path.

gsutil will not download files to my windows machine from powershell

gsutil -m cp -R 'gs://[BUCKET]/' 'C:/Users/[USER]/[FOLDER]'
will display the following error
[Errno 22] invalid mode ('ab') or filename: u'C:\\Users\\[USER]\\[FOLDER]\\\\[BUCKET]\\[FILE].gstmp'
I've tried changing the '/'s to '//' to '\' and '\' with no results whatsoever
So, after hours trying to find out this was happening.. it happened that the filenames had a character that can't be used in filenames in windows.. hope this helps if anybody else runs into this error.

Gsutil with rsync: Invalid Unicode Path Enountered

I am using gsutil combined with the "rsync" command to upload a business critical files to google storage as a backup. Unfortunately most of the archives and filenames are Greek for example "αντιγραφο.txt". On english files, rsync is ok, but when gsutil tries to sync greek files, it encounters an exception.
The command is:
gsutil -m rsync -d -r H:\Test gs://myserver.com/data
Building synchronization state...
Caught non-retryable exception while listing file://H:\Test: CommandException: Invalid Unicode path encountered
('H:\Test\\xe1\xed\xf4\xe9\xe3\xf1\xe1\xf6\xef (1).txt'). gsutil
cannot proceed with such files present. Please remove or rename this
file and try again. NOTE: the path printed above replaces the
problematic characters with a hex-encoded printable representation.
For more details (including how to convert to a gsutil-compatible
encoding) see gsutil help encoding.
CommandException: Caught non-retryable exception - aborting rsync
I tried to convert the filenames to UTF-8 but I can't find anything that works on my windows cmd. I've searched many sites for iconv native2asciii but I can't locate something useful. The server is Windows 2012 so I cannot use "convmv" to convert filenames to UTF-8.Is there another way to convert all filenames to utf8 in an automated manner before I upload the to the cloud? The archive is 600GB so i can't just zip it and send it, i also want this to run automaticaly through task scheduler.
Thank you very much!

Perforce p4 sync command fails for a folder which has a space in it's name

There is a folder with the name Test Logs. As it can be seen there is a space between Test and Logs
When I try to get it locally using sync command in perl script it fails.
The script has the code:
system("p4 sync -f //depot/Test Logs/OnTargetLogs/...");
I get the following error:
> //depot/Test - no such file(s).
> Logs/OnTargetLogs/... - no such file(s).
Quote the argument maybe?
system("p4 sync -f \"//depot/Test Logs/OnTargetLogs/...\"");
– Sobrique
What you said worked. Also I found another way of doing this :
my #a1 = ("p4","sync","-f","//depot/Test Logs/OnTargetLogs/..."); system #a1;
– Vishal Khemani