I need write a bash script to export data from mysql.
The below command ran got good results in mysql shell.
Select [datacolum] from [table] into outfile 'outputfile' FIELDS TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
And I ran it in command line:
mysql -u user -ppassword database <<EOF
Select [datacolum] from [table] into outfile 'outputfile' FIELDS TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
EOF
I got exception :
ERROR 1049 (42000) at line 1: Unknown database 'n';'
Finally I realized:
The backslash escape in Ubuntu:
root@ubuntu:~# echo '\'
\
root@ubuntu:~# echo "'\'"
'\'
root@ubuntu:~# echo '\\'
\\
root@ubuntu:~# echo "'\\'"
'\'
So the correct ran the above sql in command line should be:
mysql -u user -ppassword database <<EOF
Select [datacolum] from [table] into outfile 'outputfile' FIELDS TERMINATED BY ',' ESCAPED BY '\\\\' LINES TERMINATED BY '\r\n';
EOF
Thursday, March 8, 2018
Monday, February 5, 2018
Sed -i change the text start with space
I met a issue that want use sed to replace a line start with space. and new line also start with space.
Just like new line want keep indentation as before.
replaced=" def"
sed -i "/ abc/c $replaced" temp.txt
in this case , the new line will lost the space , no indentation
The way to do it :
replaced="\ def"
sed -i "/ abc/c $replaced" temp.txt
Just like new line want keep indentation as before.
replaced=" def"
sed -i "/ abc/c $replaced" temp.txt
in this case , the new line will lost the space , no indentation
The way to do it :
replaced="\ def"
sed -i "/ abc/c $replaced" temp.txt
This will keep space after the replacement.
Tuesday, October 3, 2017
How to digital sign the one click installer build by wix
I sign the wix build one click installer. use signtool , got below exception:
i336: Acquiring container: WixAttachedContainer, copy from: C:\Users\test\Desktop\TestInstaller.exe
i000: Setting string variable 'WixBundleLastUsedSource' to value 'C:\Users\test\Desktop\'
e000: Error 0x80070001: Failed to extract all files from container, erf: 1:2:0
e000: Error 0x80070001: Failed to wait for operation complete.
e000: Error 0x80070001: Failed to open container.
e000: Error 0x80070001: Failed to open container: WixAttachedContainer.
e312: Failed to extract payloads from container: WixAttachedContainer to working path: C:\Users\test\AppData\Local\Temp\{8d17e055-d90d-4704-a556-bd5807e85920}\6C513FAEDC30F50DCA80F4305E027697FF9E50F8, error: 0x80070001.
e000: Error 0x80070001: Failed while caching, aborting execution.
i330: Removed bundle dependency provider: {8d17e055-d90d-4704-a556-bd5807e85920}
i352: Removing cached bundle: {8d17e055-d90d-4704-a556-bd5807e85920}, from path: C:\ProgramData\Package Cache\{8d17e055-d90d-4704-a556-bd5807e85920}\
i399: Apply complete, result: 0x80070001, restart: None, ba requested restart: No
to fix it:
1. Build your bundle (using candle/light).
My light output was "TestInstaller.exe"
2. detach the engine from TestInstaller.exe:
insignia -ib TestInstaller.exe -o engine.exe
3. sign engine.exe with your certificate:
4. re-attach the signed engine.exe to the bundle:
insignia -ab engine.exe TestInstaller.exe -o TestInstaller.exe
5. sign TestInstaller.exe with your certificate.
Thanks Jonks,
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Burn-3-8-1128-Error-0x80070001-Failed-to-extract-all-files-from-container-erf-1-2-0-td7593695.html
i336: Acquiring container: WixAttachedContainer, copy from: C:\Users\test\Desktop\TestInstaller.exe
i000: Setting string variable 'WixBundleLastUsedSource' to value 'C:\Users\test\Desktop\'
e000: Error 0x80070001: Failed to extract all files from container, erf: 1:2:0
e000: Error 0x80070001: Failed to wait for operation complete.
e000: Error 0x80070001: Failed to open container.
e000: Error 0x80070001: Failed to open container: WixAttachedContainer.
e312: Failed to extract payloads from container: WixAttachedContainer to working path: C:\Users\test\AppData\Local\Temp\{8d17e055-d90d-4704-a556-bd5807e85920}\6C513FAEDC30F50DCA80F4305E027697FF9E50F8, error: 0x80070001.
e000: Error 0x80070001: Failed while caching, aborting execution.
i330: Removed bundle dependency provider: {8d17e055-d90d-4704-a556-bd5807e85920}
i352: Removing cached bundle: {8d17e055-d90d-4704-a556-bd5807e85920}, from path: C:\ProgramData\Package Cache\{8d17e055-d90d-4704-a556-bd5807e85920}\
i399: Apply complete, result: 0x80070001, restart: None, ba requested restart: No
to fix it:
1. Build your bundle (using candle/light).
My light output was "TestInstaller.exe"
2. detach the engine from TestInstaller.exe:
insignia -ib TestInstaller.exe -o engine.exe
3. sign engine.exe with your certificate:
4. re-attach the signed engine.exe to the bundle:
insignia -ab engine.exe TestInstaller.exe -o TestInstaller.exe
5. sign TestInstaller.exe with your certificate.
Thanks Jonks,
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Burn-3-8-1128-Error-0x80070001-Failed-to-extract-all-files-from-container-erf-1-2-0-td7593695.html
Subscribe to:
Posts (Atom)