How to send a command containing an apostrophe in teraterm - apostrophe

I am trying to send the following command using TeraTerm macro:
ubus call uci add '{"config":"wireless", "type":"wifi-iface", "name": "default_radio11"}'
so I am using the send command:
Send 'ubus call uci add '{"config":"wireless", "type":"wifi-iface", "name": "default_radio11"}''
The problem is that TeraTerm sends only ubus call uci add (since I have an apostrophe after add).

I found the solution:
You need to split the command:
send 'ubus call uci add '
send #39
send '{"config":"wireless", "type":"wifi-iface", "name": "default_radio11"}'
sendln #39
Note: #39 means ' in ASCII

Related

Call textinput.py from another python file

How can I call textinput.py from another python file? I would like to call it and send a text query as an argument rather than getting the input from the user.
Thank you
I 've used this method and it is working. I hope it is the correct way.
import os os.system('/home/pi/env/bin/python3 textinput.py --query \'XXXX\' --device-id XXX --device-model-id XXXXXX')

How to pass pipeline variables to post build gerrit message?

I have a Pylint running in a Jenkins pipeline. To implement it, I used Gerrit trigger plugin and Next Generation Warnings plugin. Everything is working as expected - Jenkins is joining the review, checks change with pylint and generates report.
Now, I'd like to post pylint score in a custom "Build successful" message. I wanted to pass the pylint score to a environment variable and use it in dedicated window for Gerrit plugin message.
Unfortunately no matter what I try, I cannot pass any "new" variable to the message. Passing parameters embedded in pipeline works (e.g. patchset number).
I created new environment variable in Configure Jenkins menu, tried exporting to shell, writing to it (via $VAR and env. syntax) but nothing works - that is, build message displays raw string like $VAR instead of what variable contains.
What should I do to pass local pylint score (distinct for every pipeline occurence) to the custom build message for Gerrit?
I don't think the custom message can be used for this. This is just supposed to be a static message.
They way I do this is to use the SSH command to perform the review. You can also achieve the same using the REST API.
First I run my linting and white space checking script that will generate a json file with the information I would like to pass to Gerrit. Next I send it to Gerrit using SSH. See below my pipeline script and an example json file.
As a bonus I have added the robot comments. This will now show up in your review as a remark from Jenkins that line 8 of my Jenkins file has a trailing white space. You can easily replace this with your lint result of you like or just ignore it and only put the message. It is easier to use a json file as it will make it easier to create multi line messages
node('master') {
sh """
cat lint_change.json | ssh -p ${env.GERRIT_PORT} ${env.GERRIT_HOST} gerrit review ${env.GERRIT_PATCHSET_REVISION} --json
"""
}
Example json file:
{
"labels": {
"Code-Style": "-1"
},
"message": "Lint Bot Review\nLint Results:\n Errors: 0\n Warnings: 0\n\nWhitespace results:\n Errors: 1",
"robot_comments": {
"Jenkinsfile": [
{
"robot_id": "lint-bot",
"line": "8",
"message": "trailing whitespace."
}
]
}
}
Alternatively, you may want to look at a new gerrit-code-review-plugin that should make this things even easier. However, I have not tried this yet.

Linux expect newline

I have a custom package I want to install automatically in my docker using expect.
The first thing the package asks me to do is press Enter to continue, then it prints another 2 empty lines then it waits for an input.
My expect script :
#!/usr/bin/expect -f
set timeout -1
spawn ./install
expect "\n"
send -- "\n"
But as you can see in the image, it just runs the installer and exits.
I tried removing the expect "\n" so only send -- "\n" will execute but now even the install message doesn't appear (tried with set timeout 1000 before send and it also didn't work)
Any ideas?
P.S : This is a link to the package if anyone wants to have a go at it:
https://www.bayometric.com/downloads/digital-persona/DP_UareU_Linux223_20140429.2.zip
(the installer is inside DP-UareU-RTE-2.2.3-1.20140429_1533.tar.gz)
expect "\n" match a linefeed exactly, I think this is not what your program is sending.
To wait for a Shell prompt you can use expect "%" or expect "*" to match anything.
If you need to make sure you're dealing with the right prompt you may be able to use something like expect "*Linux Installation*".
Also don't send \n but \r for the enter key :
#!/usr/bin/expect
spawn ./install
expect "*Linux Installation*"
send "\r"
expect eof
Note that the default flag is -gl for glob pattern matching but you can also use the -re flag for regular expression matching.

What is the proper way to execute a batchfile with multiple params?

I have a batchfile which I use for managing the translation of various programs.
Now I want a delphi application to call this batchfile and pass on the parameter it needs for further processing. Unfortunately the parameters contain spaces which leads to a splitup. Is there a way to keep all parameters tied up as intended?
this is how my batchfile looks:
ECHO Scan for new ressources
%MLDIR%\Ml7Build.exe s %1%
ECHO Import glossary for new translation
%MLDIR%\MlBuild.exe i %2%
ECHO Create translated application
%MLDIR%\Ml7Build.exe b %3%
I tried to use the ShellExecute-Command from ShellApi because I found several similar questions on SO, but none of them could help me in solving my problem. My delphi code looks like this:
param1 := ExtractFileName(hMLProj);
param2 := '-f: '+MLWorkDir+'Prev_'+ExtractFileName(hMLProj)+' -settings:Auftrag_Test.importsettings-method:2 -overwri:3 -error:2 '+ExtractFileName(hMLProj)+' ';
param3 := ExtractFileName(hMLProj);
ShellExecute(0,'open',PCHAR(MLWorkDir+'__AutomatedTranslationFUBAR.bat'),PChar(param1 +param2 +param3),nil,SW_SHOWDEFAULT);
ECHO Scan for new resources
%MLDIR%\Ml7Build.exe s %~1
ECHO Import glossary for new translation
%MLDIR%\MlBuild.exe i %~2
REM is 7 ^ omitted here?
ECHO Create translated application
%MLDIR%\Ml7Build.exe b %~3
Note that %n not %n% (n=1..9) refers to the parameter n supplied to the batch. The tilde removes "any enclosing quotes."
Parameters require to be "enclosed in quotes" (and they must be double-quotes) if they contain separators such as spaces.

How do you send a file separater in Mirth?

The HL7 receiver I am sending to is expecting a very specific end of file marker in a TCP Message:
<FS><CR>
Where <FS> is ascii 28 and <CR> is ascii 13.
We are using Mirth 2.x as our HL7 engine. The <CR> (Carriage Return) is fairly straight forward.
But how do I send the The File separator?
Here is how I was able to solve this problem.
In the source transformer I defined "Start of File" and "End of File" variables like this:
channelMap.put('SOF',String.fromCharCode(11)); // Start Of File: returns \v (vertical tab));
channelMap.put('EOF',String.fromCharCode(28,13)); // End Of File: returns <FS><CR>);
In the destination template I then did this:
${SOF}${message.encodedData}${EOF}
I wrote the messages out to temporary file and opened them in a Hex Editor. I was able to confirm that the a 0x0B (Ascii 11) was written prior to the message and the message closed with 0x1C 0x0D (Ascii 28, Ascii 13)
I'd recommend using the LLP Sender in Mirth. It can be configured to use different separator chars if needed.
My guess is that the two bytes you are seeing are the end of of segment and the end of message chars.

Resources