What is the format of this file? - file-format

What is the format of the file below?
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
[{"ImageLinks":[{"Link":"http://b2b.ser3.jpg"},{"Link":"http://b2b.a4.jpg"},{"Link":"http://b2b.a5.jpg"},{"Link":"http://b2b.a6.jpg"},{"Link":"http://b2b.a7.jpg"},{"Link":"http://b2b.a8.jpg"},{"Link":"http://b2b.a9.jpg"},{"Link":"http://b2b.a20_1.png"}],"StockCode":"105-1020","Label":"UNIV05","Status":1,"Barcode":"0271","SubCategory":"BED","Category":"APPL","MainCategory":"HOME","Price":437.61,"SpecialPrice":0.0,"StockType":"Nu","Properties":"Univ Lt","Brand":"BathandBed","StockStatus":"N","QuantityInBox":0.0},
{"ImageLinks":[{"Link": ........ and continues

Related

How to remove ^# from text file in Linux

I have output file generated from MSSQL table and i am trying to use it in Linux but it seems when i run export data from SQL Server it carries ^# junk character and it causing issue while import, How we can remove ^# from text file?
355|1|1|Build an Equipment Dashboard|build-equipment-dashboard|^#|Overview|asdf|
$ echo '355|1|1|Build an Equipment Dashboard|build-equipment-dashboard|^#|Overview|asdf|' | sed -E 's/\^#//'
355|1|1|Build an Equipment Dashboard|build-equipment-dashboard||Overview|asdf|
see man sed ...
-E means extended regex. ^ must be escaped with \ .
for a call on a textfile extend the sed-command with the -i option for inplace.
sed -Ei 's/\^#//' yourtextfile

Batch Script to remove Specials Charcters

i am trying to create a batch file , but i am unable to find.
My Requirement is below.
1) i have some group of text files like Text file 1 , Text File 2 , Text file 3.
2) Each text files contains Some Special Characters .
3) I want to remove those Special characters from All the Text files .
4) Some Specials characters are there which we can type it on Notepad.
5) So i need a batch file, which can search for special character by passing ASCII Value & Remove them .
Please let us know, it would be grateful.
////// Below is text file format
81
2016-03-13 00:13:05 2016-03-14 00:51:39 �# 81
101
2016-03-13 00:13:05 2016-03-14 03:02:48 xuyou �#
2016-03-14 03:16:06 2016-03-14 08:16:13 =M 100
2016-03-14 03:16:06 2016-03-14 08:16:13
2016-03-14 03:16:06 2016-03-14 08:16:41 Search : ��~ 100
dhfcjchjchjcdhj �
huge files are not ready f okay
~
fd
Looks like binary data.May be he easiest way will be to use Strings.exe:
strings -n 1 -a -q nottextfile >purified
and see if the purified file contains what you want.

Dynamic flat file creation using UNIX

I have a flat file "xxx.txt"
It contains various records
aaaa
bbbb
cccc
...
......
etc
My script must create multiple flat files in the name of each of these records(number of records may vary).
Like aaaa.txt, bbbb.txt,.....,etc...
Also, the text files must contain a message in all those files created,
Example:
Hi,
Welcome
Thankyou
How to do this in shell script.
Note: In Unix SunOS 5.10(solaris)
Just use a loop:
#!/bin/bash
while IFS= read -r line; do
printf "Hi\nWelcome\nThank you\n" > "${line}.txt"
done < file

List of files located in text file to be send as parameter to WinSCP in script mode

I've to create solution that is based on WinSCP and windows batch script. Below are tasks the script has to do:
Save list of files from remote directory, to file located on machine where batch script is run.
Run WinSCP in command mode (/command) using WinSCP script passed as parameter (/script=name_of_script_file.txt) and get files (get command) from previously generated list.
The most important is to get file list, save it and pass names of files located in created file to WinSCP to get them.
How to implement this?
There's no easy way to implement this using WinSCP scripting only. It's possible, see the very end of my answer, but it may not be an ideal solution.
Why do you do this in two steps? Why don't you directly download the directory?
winscp.com /command ^
"option batch abort" ^
"option confirm off" ^
"open scp://user:password#example.com/" ^
"get /path/*" ^
"exit"
If you really need the list (e.g. for some further processing), you can instead of getting a list of files in the directory, get a list of actually downloaded files.
Enable the XML logging, and get the list from the XML log.
winscp.com /xmllog=log.xml /command ^
....
You get a log like:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="user#host" start="2015-01-30T06:45:57.008Z">
<download>
<filename value="/path/file1.txt" />
<destination value="C:\path\file1.txt" />
<result success="true" />
</download>
<download>
<filename value="/path/file2.txt" />
<destination value="C:\path\file2.txt" />
<result success="true" />
</download>
</session>
If you need a plain-text list, you can use the XSLT to convert it (e.g. download.xslt):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="http://winscp.net/schema/session/1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match='winscp:download[winscp:result[#success="true"]]/winscp:filename'>
<xsl:value-of select="#value"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
To process it, use any XSLT processor:
Microsoft msxsl.exe (deprecated, but available from Internet Archive)
msxsl.exe log.xml download.xslt
Libxml2 xsltproc.exe:
xsltproc.exe download.xslt log.xml
And you get:
/path/file1.txt
/path/file2.txt
See Transforming XML Log to Text Output Using XSLT Transformation.
To answer your actual question. If you really insist on getting a file list and downloading files according to it, I suggest you use the WinSCP .NET assembly from a PowerShell script.
Use the Session.ListDirectory to retrieve a contents of a remote directory.
See the Session.ListDirectory documentation and its example code.
For recursive listing, you can also use the Session.EnumerateRemoteFiles.
Iterate the results and call the Session.GetFiles for every file.
See the Session.GetFiles documentation and its example code.
If the simple scripting is your preference:
The only way to obtaining a plain text list of remote files reliably, is to use the XML logging to capture an output of the ls scripting command:
winscp.com /xmllog=log.xml /command ^
"option batch abort" ^
"option confirm off" ^
"open scp://user:password#example.com/" ^
"ls /path" ^
"exit"
You get a log like:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="user#host" start="2015-01-30T07:08:27.749Z">
<ls>
<destination value="/path" />
<files>
<file>
<filename value="." />
<type value="d" />
<modification value="2014-07-28T07:06:49.000Z" />
<permissions value="rwxr-sr-x" />
</file>
<file>
<filename value=".." />
<type value="d" />
<modification value="2015-01-23T12:22:44.000Z" />
<permissions value="rwxr-xr-x" />
</file>
<file>
<filename value="file1.txt" />
<type value="-" />
<size value="1306091" />
<modification value="2015-01-29T23:58:12.000Z" />
<permissions value="rw-rw-rw-" />
</file>
<file>
<filename value="file2.txt" />
<type value="-" />
<size value="88" />
<modification value="2007-11-17T22:40:43.000Z" />
<permissions value="rw-r--r--" />
</file>
</files>
<result success="true" />
</ls>
</session>
Again, use the XSLT to convert the XML log to a plain-text list of files:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="http://winscp.net/schema/session/1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match='winscp:file[winscp:type/#value="-"]/winscp:filename'>
<xsl:value-of select="#value"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
You get:
file1.txt
file2.txt
To get WinSCP script to download files according to a plain-text list, see scripting example Uploading a list of files. It's for an upload, but just replace the put with the get and reverse an order of arguments to turn it to a download.
Note that the /command parameter does not enter a "command" (scripting?) mode. It's for passing scripting commands on a command line (as used in my answer). You are using a script file (/script). There's no point adding an empty /command parameter to it.
See the documentation of WinSCP scripting command-line parameters.

How to add a folder to 7z archive using 7za?

I am having a bad time with the standalone version of 7-Zip. I want to compress a folder with a password. I tried: 7za a my_folder -pmy_password. It's compressing all the files in which 7za.exe is located with file name of my_folder.
BTW: I am using a scripting language called AutoIt.
As per Command Line Syntax (7zip.chm) > Contents > Command Line Version > Syntax :
7za <command> [<switch>...] <base_archive_name> [<arguments>...]
<arguments> ::= <switch> | <wildcard> | <filename> | <list_file>
<switch>::= <switch_symbol><switch_characters>[<option>]
<switch_symbol> ::= '/' | '-'
<list_file> ::= #{filename}
a is the command.
-pmy_password is a switch and should be therefore after the command and not at end. But switches can be also appended after base archive file name although this makes it more difficult to read and parse.
my_folder should be an argument, but is interpreted as base archive file name because you have not specified any archive file name.
So try:
7za.exe a -r -pmy_password MyArchive.zip my_folder

Resources