BATCH file: Scan an imput result for numbers - batch-file

I'm handling a bat file basically to redirect a streaming media content to VLC, my goal is to pratically automate the whole following steps:
Open the program that bridges the video stream to VLC (DONE)
the program gives a list of available resolutions to use as below:
[cli][info] Found matching plugin ustreamtv for URL
blablabla.com/channel/test
Available streams: 480p+ (best), 480p+_alt_akamai,
480p+_alt_highwinds, mobile_240p (worst)
Now what i need to do is basically find a way to "scan" this information for numbers in order to automate the following string
"C:\Program Files (x86)\Livestreamer\livestreamer.exe"
ublablabla.com/channel/test %quality%"p+_alt_highwinds" > nul
%quality% is there only because I'm currently typing manually whatever resoloution comes out in "Available streams:" to complete the string.
Ther's any way i can filter this result like if there is a 3 digits number before p+_alt_highwinds and automatically complete the string?
I'm sorry if this question looks like a complete mess.

Related

JMeter: How to decode alphanumeric characters fetched in JMETER response to its valid value?

I have a JMeter test plan which basically downloads a file by breaking it into multiple parts.
However, these parts are received in encoded alphanumeric character format.
For instance, we have a .txt file which is broken down into 2 parts. Each part has an encoded set of characters. I have been successful so far in appending these characters into another file.
Is there a way of restoring the contents of this file ( holding alphanumeric characters) into the original .txt file with its valid contents back again?
e.g. JMeter response: <data> aWJiZWFuLFBhbmFtYSxDb3NtZXRpY </data>
Can someone please suggest the steps to achieve this?
It looks like it is Base64-encoded, you can use __base64Decode() function (can be installed as a part of Custom JMeter Functions bundle using JMeter Plugins Manager)
${__base64Decode(aWJiZWFuLFBhbmFtYSxDb3NtZXRpY,)}
If you don't have possibility or unwilling to use JMeter Plugins you can achieve the same using JMeter's built-in __groovy() function:
${__groovy(new String('aWJiZWFuLFBhbmFtYSxDb3NtZXRpY'.decodeBase64()),)}

camel aggregate lines and split into files of different sizes

My route read a file with a number of lines and filter some lines out.
It split the file on lines and filter and aggregate to a file.
The file uri is in append mode so each aggregation is appended to it. A done file is created everytime I write to it.
After the file is fully written to, another route picks up the file.
This route split the file into files of n files of equal number of records. But I am running into an issue where the done file is updated for every aggregation in step 1.
How do I update the done file only when the aggregation is fully done ?
I tried to use property ${exchangeProperty.CamelBatchComplete} in the route1.
But that property is always set to true on aggregation...
Its harder to help with just a bit confusing description of your use-case without some basic code example. However you can just write the done file yourself when you are done, its a few lines of Java code

Extracting and Displaying data from text file in C

I am trying to write a C program that takes in two arguments, either [-url | -phone | -email] and a text file that the user will download from a website.
After the user inputs the flag and the name of the text file, the program is supposed to extract and display the contents based on the regular expression I have developed.
For example, for URL the regex is
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
I am having a hard time figuring out how I can implement such a task. Do I need to use fork()? How exactly can I read the data from the text file and display back results based on the regex?
Here is the example OUTPUT
$ gcc –o minor1 minor1.c
$ ./minor1
Usage:
./minor1 [-url | -email | -phone] input_file
URL CASE SCENARIO:
$./minor1 -url index.html
https://www.web.edu/
...
http://webpreview.web.edu/
...
httpL//policy.web.edu/
Based on the flag and the input file, this is what it is supposed to return
You may use curl to download the file from the web.
How to download a file from a URL in C, as a browser would?
C program for downloading files with curl
Then you can iterate and parse the data to extract the regex pattern of either url, email or phone.
Try to come out with some code yourself and if there is any problem, post what you did, snippet of the code that failed, and explain your own thoughts on why do you think it failed.

Trouble with running words through text files and counting them

Python 3+
This is the error i get
This is my code
I want the user to input some words, then the program should run each word through my two textfiles, if the word exists in any of them, I want the program to add +1 to the positive/negative count list.
Thank you for your help :)
Seems like you have stumbled upon a Decoding error when trying to open one of the input files in the wordlist function. it is usually hard to determine the encoding used for a particular file. so you could :
1.Try opening the file with a different encoding such as ISO-8859-15,etc.
def OpenFile():
try:
with open("My File.txt",mode="r",encoding="IS0-8859-15")
#do process My File
except UnicodeDecodeError:
print("Something went Wrong Try a different file encoding")
else:
#everything was okay, return the required
finally:
# clean up here
2. Look it modules that try and determine the correct encoding for the file such as the chardet module
Install the
chardet module :
sudo pip3 install chardet
you can run it at the command line with your file as the Argument to determine the encoding
cd /path/to/File/
chardetect My\ File.txt
this should return the likely encoding for the given file
3.You can use the chardet module inside your python code however this is recommended in a case where you will be opening a file you do not have access to e.g at a clients computer whom wants to open another specified file
and reopening the same file and redetecting the encoding will cause your program to be slow.
First of all positive_count and negative_count should be integers and not lists. If you wish to count, adding 1 to the list isn't really what you're trying to accomplish.
Second of all, the UnicodeDecodeError is there because the encoding of the underlying file is not utf-8. Did you try utf-16 or utf-16-le? In case you're using Windows, utf-16-le is probably the encoding used unless you're using code-points in which case guessing will be a nightmare.

identifying data file type

I have a huge 1.9 GB data file without extension I need to open and get some data from, the problem is this data file is extension-less and I need to know what extension it should be and what software I can open it with to view the data in a table.
here is the picture :
Its only 2 lines file, I already tried csv on excel but it did not work, any help ?
I have never use it but you could try this:
http://mark0.net/soft-tridnet-e.html
explained here:
http://www.labnol.org/software/unknown-file-extensions/20568/
The third "column" of that line looks 99% chance to be from php's print_r function (with newlines imploded to be able to stored on a single line).
There may not be a "format" or program to open it with if its just some app's custom debug/output log.
A quick google found a few programs to split large files into smaller units. THat may make it easier to load into something (may or may not be n++) for reading.
It shouldnt be too hard to mash out a script to read the lines and reconstitute the session "array" into a more readable format (read: vertical, not inline), but it would to be a one-off custom job, since noone other than the holder of your file would have a use for it.

Resources