Add Multiple Searches in cmd Find Command - cmd

I am looking for adding array or multiple searches in the Find command of cmd but as soon i tried it do nothing following command worked fine with one input.
For one Input:
Find /V "/1001214955/" Scan-FtpOut.txt > Ftp_New.txt
For multiple inputs:
Find /V "/1001214955/ | /WENP/ " Scan-FtpOut.txt > Ftp_New.txt
Find /V "/1001214955/ -o /WENP/" Scan-FtpOut.txt > Ftp_New.txt
nothing is working please assist.

As a follow up to my comment, and to show you that my commented commands work exactly as given, (to remove all lines within Scan-FtpOut.txt which contain the exact string /1001214955/ or which contain the exact case sensitive string /WENP/, and output those to Ftp_New.txt).
Here is an example Scan-FtpOut.txt file:
200 PORT command successful.
150 Opening data connection for /WENP/Faketest (467 bytes).
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
200 PORT command successful.
150 Opening data connection for /1001214955/Faketest (467 bytes).
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
Here are the contents of Ftp_New.txt after running #%SystemRoot%\System32\findstr.exe /R /V "\/1001214955\/ \/WENP\/" "Scan-FtpOut.txt" 1>"Ftp_New.txt":
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
Here are the contents of Ftp_New.txt after running #%SystemRoot%\System32\findstr.exe /R /V "[/]1001214955[/] [/]WENP[/]" "Scan-FtpOut.txt" 1>"Ftp_New.txt":
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec
Here are the contents of Ftp_New.txt after running #%SystemRoot%\System32\findstr.exe /L /V /C:"/1001214955/" /C:"/WENP/" "Scan-FtpOut.txt" 1>"Ftp_New.txt":
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec.
200 PORT command successful.
226 Transfer complete.
467 bytes transferred in 2.845 seconds. Transfer rate 0.167KB/sec
As you can see the results of each of my initially offered commands show exactly the intended results!

do it with 2 commands
Find /V "/1001214955/ | /WENP/ " Scan-FtpOut.txt > Ftp_New.txt send {Enter}
Find /V "/1001214955/ -o /WENP/" Scan-FtpOut.txt > Ftp_New.txt send {Enter}

The PowerShell that is available on all supported Windows systems has a much more complete implementation of regex than does findstr.exe. Using a PowerShell regex means you can use the many sources of regex information available on the net.
Based on https://stackoverflow.com/a/7801667/447901, here is how it could be done in a [cmd] script or command.
powershell.exe -NoLogo -NoProfile -Command ^
"(Select-String -Pattern '^(?!.*(/1001214955/|/WENP/)).*$' -Path .\Scan-FtpOut.txt).Line >'.\Scan-FtpOut-New.txt'"
It would be less convoluted and more easily understood if the script is written in [powershell] and not [cmd].

Related

Mainframe pkunzip generates PEX013W Record(s) being truncated to lrecl=

I'm sending binary .gz files from Linux to z/OS via ftps. The file transfers seem to be fine, but when the mainframe folks pkunzip the file, they get a warning:
PEX013W Record(s) being truncated to lrecl= 996. Record# 1 is 1000 bytes.
Currently I’m sending the site commands:
SITE TRAIL
200 SITE command was accepted
SITE CYLINDERS PRIMARY=50 SECONDARY=50
200 SITE command was accepted
SITE RECFM=VB LRECL=1000 BLKSIZE=32000
200 SITE command was accepted
SITE CONDDISP=delete
200 SITE command was accepted
TYPE I
200 Representation type is Image
...
250 Transfer completed successfully.
QUIT
221 Quit command received. Goodbye.
They could read the file after the pkunzip, but having a warning is not a good thing.
Output from pkunzip:
SDSF OUTPUT DISPLAY RMD0063A JOB22093 DSID 103 LINE 25 COLUMNS 02- 81
COMMAND INPUT ===> SCROLL ===> CSR
PCM123I Authorized services are unavailable.
PAM030I INPUT Archive opened: TEST.FTP.SOA5021.GZ
PAM560I ARCHIVE FASTSEEK processing is disabled.
PDA000I DDNAME=SYS00001,DISP_STATUS=MOD,DISP_NORMAL=CATALOG,DISP_ABNORMAL=
PDA000I SPACE_TYPE=TRK,SPACE_TYPE=CYL,SPACE_TYPE=BLK
PDA000I SPACE_PRIMARY=4194304,SPACE_DIRBLKS=5767182,INFO_ALCFMT=00
PDA000I VOLUMES=DPPT71,INFO_CNTL=,INFO_STORCLASS=,INFO_MGMTCLASS=
PDA000I INFO_DATACLASS=,INFO_VSAMRECORG=00,INFO_VSAMKEYOFF=0
PDA000I INFO_COPYDD=,INFO_COPYMDL=,INFO_AVGRECU=00,INFO_DSTYPE=00
PEX013W Record(s) being truncated to lrecl= 996. Record# 1 is 1000 bytes.
PEX002I TEST.FTP.SOA5021
PEX003I Extracted to TEST.FTP.SOA5021I.TXT
PAM140I FILES: EXTRACTED EXCLUDED BYPASSED IN ERROR
PAM140I 1 0 0 0
PMT002I PKUNZIP processing complete. RC=00000004 4(Dec) Start: 12:59:48.86 End
Is there a better set of site commands to transfer a .gz file from Linux to z/OS to avoid this error?
**** Update ****
Using SaggingRufus's answer below, it turns out it doesn't much matter how you send the .gz file, as long as it's binary. His suggestion pointed us to the parameters sent to the pkunzip for the output file, which was VB and was truncating 4 bytes off the record.
Because it is a variable block file, there are 4 bytes allocated to the record attributes. Allocate the file with an LRECL of 1004 and it will be fine.
Rather than generating a .zip file, perhaps generate a .tar.gz file and transfer it to z/OS UNIX? Tar is shipped with z/OS by default, and Rocket Software provides a port of gzip that is optimized for z/OS.

Rsync include or exclude directories using text file

I'm using rsync to backup some data from a remote host.
this is how I'm using the rsync cmd:
rsync --dry-run -avhi -e ssh --include-from=/home/rsync_list/test.txt root#10.10.4.61:/ /mnt/BACKUP/my_BACKUP/
this is the file /home/rsync_list/test.txt
+ /usr/acs/conf/**
+ /usr/acs/bin/**
+ /raid0/opmdps/TEMP_folder/**
- *
I want to copy only the listed folders excluding the remaining files.
I always get
receiving file list ... done
sent 103 bytes received 48 bytes 302.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
Could you tell me what I'm doing wrong? How should I write the rsync command if I would like to sync, for example, only /raid0/opmdps/TEMP_folder/ without its subfolders?
I wonder if you really only tried with the command you posted?
Not only you are using "--dry-run" option, even the output indicates this:
total size is 0 speedup is 0.00 (DRY RUN)
Please consult the manpage:
-n, --dry-run perform a trial run with no changes made
https://linux.die.net/man/1/rsync
May I suggest you give it a run without --dry-run?

Batch/cmd: saving ping logs to a file and getting the summary paragraph afterwards

I'm trying to use ping to monitor my internet connection overnight and watch for connection dropouts, packet loss, latency spikes, and so on. I have a batch file that pings google each second and records the results to a file:
#echo off
ping -t www.google.com|cmd /q /v /c "(pause&pause)>nul & for /l %%a in () do (set /p "data=" && echo(!time! !data!)&ping -n 2 localhost>nul" > ping_logs_google.txt
And I get output like this:
16:36:50.47 Pinging www.google.com [209.85.202.106] with 32 bytes of data:
16:36:51.50 Reply from 209.85.202.106: bytes=32 time=31ms TTL=47
16:36:52.52 Reply from 209.85.202.106: bytes=32 time=31ms TTL=47
16:36:53.54 Reply from 209.85.202.106: bytes=32 time=30ms TTL=47
16:36:54.58 Reply from 209.85.202.106: bytes=32 time=29ms TTL=47
16:36:55.61 Reply from 209.85.202.106: bytes=32 time=32ms TTL=47
16:36:56.64 Reply from 209.85.202.106: bytes=32 time=32ms TTL=47
.. and so on. However, when I press Ctrl-C or whatever to stop the task, I want to get the summary paragraph at the end. The one that looks like this:
Ping statistics for 209.85.202.106:
Packets: Sent = 9, Received = 9, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 29ms, Maximum = 34ms, Average = 30ms
Control-C
^C
Now, this does work when I press Ctrl-C after running just "ping -t www.google.com" in the command window itself -- it just doesn't work when I run it from the batch file. How do I make it so that I get the summary paragraph at the end when I'm finished with the batch file?
Instead of running continuously with -t, replace with "-n 100", where "100" is the number of times it will ping (or 1000 if you like). This will give you the summary at the end of your output file the same way it does in the command window. However, you'll want to remove any pauses, etc. and just it rip.

Pentaho "Get file from FTP" times out

Pentaho's get file from FTP step fails randomly. Sometimes it properly downloads the file, sometimes it doesn't returning error:
Error getting files from FTP : Read timed out
The timeout is set to 100 seconds and the read actually fails after less than one seconds.
Contrary to what the Get a file from FTP documentation says about the timeout, it is not in seconds, but in milliseconds.
Change it to any reasonable value like 60000 (1 minute in ms) and your import will work.

FTP Client Output Response standard

After successful FTP file transfer, the the response is used to be "226 File send OK", but suddenly, it has changed to be "226 Transfer complete"
I have below questions:
Does FTP response code has any standard?
Can we customize FTP output response for a specific status code?
Find the standard FTP response for file transfer
$ ftp canopus
Connected to canopus.austin.century.com.
220 canopus.austin.century.com FTP server (Version 4.1 Sat Nov 23 12:52:09 CST 1991) ready.
Name (canopus:eric): dee
331 Password required for dee.
Password:
230 User dee logged in.
ftp> pwd
257 "/home/dee" is current directory.
ftp> cd desktop
250 CWD command successful.
ftp> type ascii
200 Type set to A.
ftp> send typescript
200 PORT command successful.
150 Opening data connection for typescript (128.114.4.99,1412).
226 File send OK.
ftp> cdup
250 CWD command successful.
ftp> bye
221 Goodbye.
Note: suddenly the response text 226 File send OK has changed to 226 Transfer complete
Find the details about FTP responses on wikipedia
RFC 959, 4.2. FTP REPLIES:
An FTP reply consists of a three digit number (transmitted as
three alphanumeric characters) followed by some text. The number
is intended for use by automata to determine what state to enter
next; the text is intended for the human user. It is intended
that the three digits contain enough encoded information that the
user-process (the User-PI) will not need to examine the text and
may either discard it or pass it on to the user, as appropriate.
In particular, the text may be server-dependent, so there are
likely to be varying texts for each reply code.

Resources