"Missing parameter for command 'get'" when downloading files within date range using WinSCP - ftp

I am using below command to download files from FTP but I am getting error
"get -filemask="*>=2018-12-01" -preservetime -resume -speed=5000 /ECC/PITR/WAL_ARCHIVE E:\ECC\PITR\WAL_ARCHIVE\" ^
"exit"
Error:
> 2020-12-17 12:46:50.392 Script: get -filemask=*
< 2020-12-17 12:46:50.392 Script: Missing parameter for command 'get'.

You have the quotes wrong.
Either double the inner quotes:
"get -filemask=""*>=2018-12-01"" -preservetime -resume -speed=5000 /ECC/PITR/WAL_ARCHIVE E:\ECC\PITR\WAL_ARCHIVE\" ^
Or as the quotes around the file mask are redundant, as there's no space in the mask, you can remove them altogether:
"get -filemask=*>=2018-12-01 -preservetime -resume -speed=5000 /ECC/PITR/WAL_ARCHIVE E:\ECC\PITR\WAL_ARCHIVE\" ^
See also Why are some WinSCP scripting commands specified in a batch file not executed/failing?
If you want to avoid downloading folders, that do not contain any relevant files, see Download files newer than X days from SFTP server with WinSCP, skipping folders that do not contain any matching files.

Is the connection open before calling get?
https://winscp.net/forum/viewtopic.php?t=11089
..."Script: Missing parameter for command 'get'."...
martin:
winscp.exe /console /command "option batch abort" "open root:password#192.168.1.11/private/var/root/folder1/" "get file1 c:\Users\me\Desktop\folder2"

Related

SSIS inserting space in computed variable for "Execute Process Task"

I'm using SSIS in conjunction with WinSCP to push a file. Everything seemed to be going OK, but I'm getting an error. It looks like SSIS is, at some point, putting a "phantom space" into my variable for some reason.
The variable is set up like this:
"/command \"open sftp://" + #[User::SFTP_User]+":"+ #[User::SFTP_Pass] + "#" + #[User::SFTP_Site] + " -hostkey=\"\"ssh-rsa 2048 "+ #[User::SFTP_Hostkey] +"\"\"\" \"put -nopreservetime "+ #[User::InventoryFile] + " " + #[User::PurchaseFile] + " " + #[User::SFTP_Location] + "\" \"exit\""
and is used as the script string for WinSCP.com.
When I take the computed value and copy it into Notepad++, I get something like
/command "open sftp://USER:Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"
HOWEVER!!! Copying/pasting this to the command line, rather than notepad++, however, yields
/command "open sftp://USER: Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"
ALSO!!! when I run the package, I get an error message:
Error: 0xC0029151 at WinSCP Files to MSA, Execute Process Task: In Executing "C:\Program Files (x86)\WinSCP\WinSCP.com" "/command "open sftp://USER: Pas$word#ftp.site.com -hostkey=""ssh-rsa 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00""" "put -nopreservetime \\my\path\file.csv \\my\path\file2.csv /remote/path/" "exit"" at "\\my\working\path\", The process exit code was "1" while the expected was "0".
Please notice that there is an extra " " (space) in between the "USER:" and the password. This is breaking the command. Also notice that there is an extra space in between the upload files and the upload location (however, this does not seem to have any ill effect). If I copy that whole thing to a command prompt and just remove that space after the colon, it works...
Where are these phantom spaces coming from and/or how do I get rid of them?
I was able to solve this by going into Notepad++ and using the "HEX Editor" plugin to see the hidden characters.
Even "Show all characters" was not showing the hidden characters...
I'm sure that they came from copying from formatted text into the variable. It was really strange that in some instances you could copy/paste them without the formatting and in other circumstances the hidden characters would be there. I usually use notepad++ as a tool (intermediate copy/paste) for removing formatting, but it was not removing these devils.
Anyway, once I found the hidden characters in the HEX editor, I was able to simply remove them from there, switch back to ASCII mode, copy the string and paste it back into the SSIS program and go from there. Problem solved!
Thanks all - your ideas helped get me to the solution.

Using Rsync to read variable from text file but include wild cards in bash

i am trying to RSync files from a folder, however i would like to define a subset of these files.
I have created a text file with the wildcard names but i get a "no such file" error.
below is my source directory file list, the names will always be there, but the date/time will change so i am using the *wildcard to grab file.
20200207-COE-2020-02-06T2332238.SCH
20200207-SMXH-2020-02-06T23140696.SCH
20200207-SMXH alias-2020-02-06T23140766.SCH
20200128-SARE-2020-01-28T15202081.SCH
20200128-SARH alias-2020-01-28T15161179.SCH
my source list - i tried by entering the wild character in this and in the rsync command line
*SMXH*
*COE*
*SMXH\ alias*
my rsync command
rsync -tv --files-from=/var/tmp/red_badger/bus_names.txt "foo#bar:/apps/schedules/archived/" /var/tmp/red_badger/files --dry-run
error message
receiving file list ... rsync: link_stat "/apps/schedules/archived/*SMXH*" failed: No such file or directory (2)
rsync: link_stat "/apps/schedules/archived/*COE*" failed: No such file or directory (2)
rsync: link_stat "/apps/archived/*SMXH\ alias*" failed: No such file or directory (2)
using the wild card works in one line command
rsync -tv "foo#bar:/apps/schedules/archived/*SMXH\ alias*" .
The --files-from option is for specifying exact filename matches. To use patterns instead of actual file names, use the --include-from option instead.

7zip cmd line write a file name with underscores

this seems like a simple one but I can't find it anywhere!
I want to zip up a file with this command:
#"a -tzip -mx0 -v500m -mmt -- C:\Greg_Folder\zippedPackage.zip D:\tmp\failedImages";
This basically means that I'd like to zip up the folder "D:\tmp\failedImages" and move it to "C:\Greg_Folder\zippedPackage.zip"
THE PROBLEM: I want to zip to the "Greg_Folder" and not 'Greg Folder"... but underscores seem to be translated to spaces in the cmd line. So I need a way to say that I want the underscores to be treated literally as part of the directory name.
any ideas?
I just compressed some folder on my drive using your command without the # and the quotes.
"C:\Program Files\7-Zip\7z.exe" a -tzip -mx0 -v500m -mmt -- C:\Greg_Folder\zippedPackage.zip K:\devkitPro\devkitARM\arm-eabi
I just did not put the "#" sign which is for some other option (and your bug seems to be a strange side-effect), and it even created the "Greg_Folder" directory and the .zip.001 file inside.

SymStore - add multiple files

I am trying to add a bunch of .pdb files to the symbol server using symstore.exe. Not all the .pdb's in the dir, but a selection of them (based on date).
To add them in a single transaction I'm using symstore ... /f '#filelist.txt' where filelist.txt is a file containing the real .pdb one per line - just as the command-line help says:
/f File Network path of files or directories to add.
If the named file begins with an '#' symbol, it is treated
as a response file which is expected to contain a list of
files (path and filename, 1 entry per line) to be stored.
(This info exists only in command-line help to symstore, not in the corresponding online help page.)
This just doesn't work, it stores 0 files. I assume that this feature - adding multiple files from a file list - is just not really implemented.
Does anybody have success adding a list of files in a single transaction with symstore.exe?
Finally, I have figured that out. The feature with # and the response file is actually supported.
After using the symstore's /o switch for debugging output I have noticed a weird character ÿþC in the error output
PS C:\Development\symstore add /f #C:\temp\dllsAndPdbsToAdd.txt /s C:\temp\symstore\ /t AwesomeProject
SYMSTORE MESSAGE: 0 alternate indexers registered
SYMSTORE MESSAGE: LastId.txt reported id 8
SYMSTORE MESSAGE: Final id is 0000000008
SYMSTORE ERROR: Class: Internal. Desc: Failed to index C:\Development\AwesomeProject\ÿþC. Line: 169. Error 32
So I changed encoding of the #C:\temp\dllsAndPdbsToAdd.txt file in Notepad++ to ANSI and it worked.

7z Command Line Extract code does not extract files into specified folder

I have written a command line extract code :
7z x C:\\Users\\Anuj\\Desktop\\th.7z -p123 -oC:\\Program Files\\OpenVPN *.* -r"
Here the given Output path is :
C:\\Program Files\\OpenVPN *.* -r"
However The zip file gets extracted to :
C:\Program\
I have identified the problem too, the problem is the code cannot take spaces in file folder.if the file output is changed to C:\\ProgramFiles\\OpenVpn
It works. BUt if the path is C:\\Program Files\\OpenVPN It doesnt
I was getting the ACCESS DENIED error for the code below:
declare #unzip varchar(500)
set #unzip='"C:\Program Files\7-Zip\7z.exe" e D:\Documents\test_compress.zip -oD:\Documents\test_compress'
exec master..xp_cmdshell #unzip
All I had to do was allow the MSSQL application the FULL ACCESS control. To do that first find the application name :
exec master..xp_cmdshell 'whoami' -- nt service\mssqlserver
Now go to D:\Documents - Right Click the Documents folder - Click "Properties - Go to "Security" tab -- If MSSQLSERVER is not listed then Click "Edit" and then click "Add" -- Add "NT SERVICE\MSSQLSERVER" and now check the option "Full Control" Allow
From: http://7zip.bugaco.com/7zip/MANUAL/syntax.htm
Wildcards or filenames with spaces must be quoted:
"Dir\Program files\*"
Dir\"Program files"\*
Hope this helps.

Resources