Hi does anyone know how to get app params after "--"? So for example if I have something like:
pin -t MyTool -- somebinary input
How do I get the string "somebinary input" in MyTool. I checked the documentation but there doesn't seem to be anything I can use, or maybe I've overlooked something? Thanks.
I use the API KNOB_BASE::StringLongAll() to print all, but I didn't find the command params after "--"
Related
I'm working with expect scripting in order to ssh into a device and pull information off of it. However, I'm facing issues parsing the expect_out(buffer) for the data from the commands I send.
This is the contents of my expect_out(buffer):
"mca-cli-op info\r\n\r\nModel: UAP-AC-Lite\r\nVersion: 6.0.21.13673\r\nMAC Address: 10:9f:5r:20:c5:7e\r\nIP Address: 123.123.1.123\r\nHostname: UAP-AC-Lite\r\nUptime: 152662 seconds\r\n\r\nStatus: Connected (http://base_controller<url;>/inform)\r\nUAP-AC-Lite-BZ.6.0.21# "
Right now I'm trying to get the Model (UAP-AC-LITE) without the Model tag.
So the regex expression I'm using is,
expect -re {(?=(Model: ))+[.*\$]}
set model "$expect_out(0,string)"
puts $model
The command doesn't work, but my thought process was that I would perform a look ahead for the Model tag, then match only the subsequent characters after it to the new line. I've tried replacing the "$" with \r\n but that doesn't work either. Can anyone explain what I'm doing wrong? Thanks for the help!
Note: If possible, I wouldn't want to include the newline either, as it might mess up commands that I run which use these variables.
You're close, but the regex is incorrect. Try
expect -re {Model:\s+([^\r]+)}
set model $expect_out(1,string)
The 1 in $expect_out(1,string) means the first set of capturing parentheses.
Regexes are documented at http://www.tcl-lang.org/man/tcl8.6/TclCmd/re_syntax.htm
I haven't used youtube-dl in a while and I do remember that I set 2 shortcuts:
one for "youtube-dl -F"
another one for "youtube-dl -f"
the shortcut is something simple like xx for 'youtube-dl -F' so that in the command line, I would just type xx [URL]
Now the thing is I dont know how I set it actually at that time and moreover I cant seem to remember what those shortcuts are (maybe they got deleted or so.. I am not sure)
Hoping someone can help me out on how to set them OR point me to a webpage where I can get those set of instructions.
someone in a different forum helped me figure it out.
I used 'aliases' in my zsh shell on iterm2.
Apparently I set 'sd' for "youtube-dl -F" & 'sdd' for "youtube-dl -f"
I'm trying to create an AppleScript to delete messages conversations that match a particular regex pattern. I tried to follow an example I found, but it seems to be using code that no longer works (perhaps High Sierra limitations).
The following is the code doesn't seem to work.
set chatsToKill to {}
tell application "Messages"
set allChats to every chat
repeat with eachChat in allChats
--
-- The example fails because ScriptEditor would error saying it could get participants of the value returned for the first (or any of eachChat).
--
set thePeeps to participants of eachChat
repeat with oneParticipant in thePeeps
set theHandle to handle of oneParticipant
try
do shell script "echo " & quoted form of theHandle & " | egrep '^SMS;-;141'"
if chatsToKill does not contain eachChat's id then set end of chatsToKill to eachChat's id
end try
end repeat
end repeat
repeat with deathChat in chatsToKill
-- This should be a delete of the deathChat
end repeat
end tell
Perhaps things have changed since that script was written, but it is flawed and will not work, and I'm not sure it can be made to work as of macOS 10.11.6+.
Apple has greatly limited scripting access to the Messages app.
When I step through your script, I get an error on this line:
set thePeeps to participants of eachChat
The error is:
Messages got an error: Can’t get participants of text chat id
"iMessage;-;+1123121234".
Even when I put the code in a try/catch block, it failed for all messages.
Even if that worked, I don't see how the remainder of your script would work. You execute a do shell script without assigning the results to anything.
You need something like this:
set scriptResults to do shell script "echo " & quoted form of theHandle & " | egrep '^SMS;-;141'"
-- do something with scriptResults
if chatsToKill does not contain eachChat's id then set end of chatsToKill to eachChat's id
Sorry I can't offer something better.
I have an expect script and user prompt is ">" . I create my script expecting ">" to send the next command, but unfortunately, ">" is also coming as part of the output received of the previous sent command, thereby causing my script to send the next command, how shoul I control when ">" coming as prompt and when as part of output?
Maybe something like:
^\w+#\w+(\.\w+)?>$
I am trying to automate the configuration of a server using perl and the expect module. I have been using the expect module three days but now I have encountered a problem that I can't solve.
My problem is when im executing a command that prints no output if it is successful but prints an error message if something went wrong. An example of such command is the cd command:
$ cd .
$
$ cd sadjksajdlaskd
sadjksajdlaskd: No such file or directory.
$
What I would like to do is to send the command to the server, and then perform an expect call to check if something other than the prompt sign was printed. Something like this:
$com->send("cd $dir");
$com->expect(2,
["^[^$#]*", sub {
my $self = shift;
my $error = $self->match();
die "ERROR: $error";
}],
"-re", "^[$#]"
);
The problem I have is that when I perform the expect call it will match against all previous text and not against text received after the send call, so it will always match and report an error. How do I make expect match only agains the text received after the send call? Is it possible to clear the buffer of the expect module or is it possible to achieve this kind of error detection some other way?
I also wonder how the expect module handles regular expressions. If I for example use "^[$#]\$" as the regular expression to match the prompt of the terminal, will the \$ part of the regular expression match end of line or an actual dollar sign? If i remove the \ perl complains.
Thanks in advance!
/Haso
EDIT: I have found a solution:
The solution was to use $com->clear_accum() which clears the accumelator. I have tried using it before but it seems like this function only works at random, or maybe I don't understand what clear_accum() is suppose to do.
EDIT: A final note about clear_accum():
The reason the clear_accum() function seems to work at random is because the text generated from the previous send is not read into the accumelator until an expect() call is made. So in order to truly clear all previous data is to first perform an expect() call and then clear the accumelator:
#To clear all previous data
$com->expect(0);
$com->clear_accum();
akarageo#Pal4op:~> cd banana
bash: cd: banana: No such file or directory
akarageo#Pal4op:~:( > echo $?
1
i.e. check the error code that CD returns, 0 means OK anything else is an error, No need to check the prompt , and btw, the CD command does not generate the prompt the shell does, so that must be part of your confusion also.
try $object->exitstatus() if it is of any help