Im trying to send a command to a non-unix enviroment like this show configuration | grep interfaces with Paramiko (Python3.5), but I get a show configuration output. It seems paramiko does not send the | grep interfaces. Somebody knows how to solve this?
thanks
I have replaced Paramiko with Netmiko and the issue is solved.
Related
I am new to Python coding. I have a piece of shell code as below. I am attempting to convert this to Python.
cat <file> |ssh -q ${v_user}#${v_server} > /tmp/.bndchk.log
Using this through shell script, I am running a local file that has required commands over remote server through ssh.
Now, I am looking for the similar action in python as well.
Could you help me on this, please?
Thank you so much in advance.
With best wishes,
Macharla Ramesh Kumar
I have followed every single step in this tutorial. Double Checked. Double Installed.
https://nickymeuleman.netlify.app/blog/gui-on-wsl2-cypress
But I get the error :
[3974:0912/194522.792278:ERROR:browser_main_loop.cc(1402)] Unable to open X display.
The futex facility returned an unexpected error code.
The Test Runner unexpectedly exited via a exit event with signal SIGABRT
I had a similar issue, but there was a line before that same error message about Authentication. For me, I had to Disable Access Control after first ensuring all other running instances of VcXsrv were terminated:
If you've configured an external nameserver, then following the steps of Nicky Meuleman's tutorial, the DISPLAY variable will be set wrong. The tutorial says to add this to your .bashrc:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
... but if you've configured an external nameserver, DISPLAY will end up pointing to that server, and it won't work. Instead, you should do this:
export DISPLAY=$( cmd.exe /C netsh interface ip show addresses "vEthernet (WSL)" | grep "IP Address" | sed -e "s/\sIP Address:\s//g; s/\r//" ):0.0
This will set DISPLAY to (e.g.) 172.24.0.1:0.0 instead of 8.8.4.4:0.0.
To clean up, I want to see what VM instances have been stopped but not terminated. I don't think there is any policy that will terminate them automatically, and I cannot find a way to see how long the instances have been stopped. I am just working from documentation, though, so anyone with practical experience might be able to offer some advice.
If you are looking for a CLI command, IBM Cloud CLI has an infrastructure-service plugin to help you see the instance information. The instructions to set up the plugin can be found in this solution tutorial
ibmcloud is instances
You can use grep with the command to see the instances that are stopped
ibmcloud is instances | grep `stopped`
To get the ID of the stopped VM, run the following command
ibmcloud is instances | grep 'stopped' | awk '{print $1}'
I did a quick search, but failed to find the answer. Does anyone knows?
You can use the following terminal command in unix-based OSs:
node <file-name.extension> --v8-options | grep harmony
,or you can do the same on Windows platform like the following:
node <file-name.extension> --v8-options | findstr harmony
I am trying to figure out a way to make the weblogic WLST terminal run in silent mode.
When i start the terminal with the java weblogic.WLST command, it prints the lines:
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Is there a command line flag or some unknown witchcraft to make the interpreter not write these lines?
I wishfully tried -s for silent, to no avail.
And all my googling lead me to an -i flag that does something completely different.
EDIT:
To clarify my purpose:
I need the interpreter to run a python script, and i do need the output from that. The welcome message is useless clutter however, that i would like to be rid of.
Limited to:
The only problem i have is the first lines written by the interpreter itself. Once inside the python script i have no problem handling what send to the output. My only problem is the welcome lines written above. These are written by the interpreter itself, and not the python code.
To solve the problem, I did something little differente..
I put a grep -v in the output .. like this:
java weblogic.WLST script.py $ARGS | grep -v "Initializing WebLogic
Scripting Tool (WLST) ..." | grep -v "Welcome to WebLogic Server
Administration Scripting Shell" | grep -v "Type help() for help on
available commands" | grep -v "Successfully connected to Admin Server
\"AdminServer\" that belongs to domain \"domain\"." | grep -v
"Warning: An insecure protocol was used to connect to the server." |
grep -v "To ensure on-the-wire security, the SSL port or Admin port
should be used instead." | grep -v "Location changed to domainRuntime
tree. This is a read-only tree" | grep -v "with DomainMBean as the
root MBean." | grep -v "For more help, use help('domainRuntime')" |
grep -v "Successfully connected to Admin Server" | grep -v "Connecting
to t3://"
Try this:
Like you said "it's a hack", but it's a fairly elegant hack.
Create the file runwlst.sh:
#!/bin/bash
. ${WLS_HOME}/server/bin/setWLSEnv.sh >/dev/null 2>&1
FILENAME=$1
shift
java weblogic.WLST ${FILENAME} "$#" | sed -e "1,7 d"
WLS_HOME needs to be set, or use the absolute path to setWLSEnv.sh.
Then create your WLST scripts as "shell" scripts like so (I like to use the ".wlsh" extension for my scripts):
#!/bin/bash /absolute_path_to_runwlst.sh/runwlst.sh
# your WLST Python code starts here
import ...
This obviously the sed script used in runwlst.sh only works if the "Initializing" banner is 7 lines long, which could change with new releases or patches of WLS.
The benefit of this solution is that now you can just run your WLST scripts from the command line like so:
$ createManagedServer.wlsh domain servername
Or use WLST scripts is other shell scipts like so:
#!/bin/bash
PORT=`./getPortForManagedServer.wlsh domain server`
echo ${PORT}
you get the picture
I wanted for it to only show me lines that I print inside the script, so I did it simple - prepended special char sequence to all lines I wanted to see in logs (it was print('--> ...') in my case) and launched it like that:
wlst.sh changePassword.wlst.py "$#" | grep -- "-->"
Sample output:
Executing WLST script for domain SampleDomain
--> Executing credential change for SampleDomain
--> Changing DB password for DSTYPE1
--> Changing password for DataSource SampleDS1
--> Successfully changed DB credentials!
--> Changing password for DataSource SampleDS2
--> No JDBC resource with name SampleDS2 found, skipping...
--> Changing password for DataSource SampleDS3
--> No JDBC resource with name SampleDS3 found, skipping...
--> Changing password for DataSource SampleDS4
--> Successfully changed DB credentials!
Completed execution for domain SampleDomain
Bit of a long shot but you could also silence the entire JVM output by capturing stdout and stderr into a different stream and then print values captured from the weblogic mbeans to the console streams. I had to do something similar a while back after writing an ansible module which required me to return pure JSON to stdout without any message banners or other stuff printed to the terminal.
A possible solution for your needs would involve writing a python script that first changes the OutputStreams as in this example and then starts a WSLT session. Just remember to keep a "copy" of the console out streams and use these to write your results to.