Gtk-WARNING **: cannot open display: :0.0 --- Ubuntu 14.04 [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I have just installed OpenCV 3.2.0 on an amazon EC2 instance (ubuntu 14.04). When I try to run any of the sample programs I get the error Gtk-WARNING **: cannot open display: :0.0
Answers to similar questions online didn't work for me. I've tried
export DISPLAY=:0.0
export DISPLAY=:0
and I tried xhost +localhost and received xhost: unable to open display ":0.0"
This post describes the exact same problems as me, but I'm not using Vagrant, so there is no "Vagrantfile" and I don't know what the equivalent would be in an EC2 instance.
Gtk-WARNING **: cannot open display:
Does anyone have an idea of why this is happening?

I'm on Ubuntu 16.04 using ssh to Ubuntu 16.04.2 server. I can do the following:
xhost +
ssh -Y -i .ssh/my.pem ubuntu#ecxxxxxxx.eu-west-1.compute.amazonaws.com
sudo apt install x11-apps
xclock
This starts the xclock applet on my local display. Note the xhost + before I ssh and the -Y flag on the ssh command. I'm using xclock to test which I installed from x11-apps. You should be able to start OpenCV in a similar way.

Related

This code is giving error in kali linux wsl [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 days ago.
Improve this question
pacman -S --noconfirm --needed git python2 python2-beautifulsoup4 python2-pexpect python2-crypto
It gives the following error:
Error of failed request: BadName (named color or font does not exist)
Major opcode of failed request: 45 (X_OpenFont)
Serial number of failed request: 21
Current serial number in output stream: 25
I was trying to download social engineering toolkit in kali linux distribution on wsl.

Quick start with SCAPY and WIRESHARK (Including drivers) (Custom WIFI Packets) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Scapy with WIFI - From setup to use
This tutorial is supposed to help you through the setup and installation of scapy and the wifi dongle used in this tutorial.
WIRESHARK, PYTHON AND SCAPY
I spent some time with scapy and want to share my knowledge since there are lots of spots where things can go wrong. I am using the TP-Link wifi dongle TL-WN722N V2.
Operating System:
I found that first of all you need to install your own driver to be able to use frame injection and monitor mode. Windows is not an option here because monitor mode was depreciated in earlier versions. Next I tried linux.
As I am quiet new to linux myself I played around a little and found out that most tutorials on WIFI monitor mode are only working for kali linux, which is fine if you want to use it for hacking. Another operating system for which I can confirm the drivers working is Ubuntu (version 20.04.2 currently). I also tried installing the drivers on raspbian. It does not work, ubuntu server version can be installed on raspberry pi, though. I hope this saves you some trouble.
=> Use Kali or Ubuntu (desktop and server version both work for ubuntu)
Installing The Driver
After reading the above paragraph this should be quiet easy as all the tutorials made for kali linux also work for ubuntu. Below are the steps that I took to install everything:
sudo apt update
sudo apt install bc make gcc
sudo rmmod r8188eu.ko
git clone -b v5.2.20 https://github.com/aircrack-ng/rtl8812au.git
cd rtl8812au
sudo -i
echo "blacklist r8188eu" > "/etc/modprobe.d/realtek.conf"
exit
make
sudo make install
sudo modprobe 8188eu
The most common error for me appeared after calling make. This is often due to wrong kernels and can be fixed by switching to ubuntu or kali as this has to do with the operating system.
Do not forget to reboot before the next steps.
Turn On Monitor Mode
This is also somewhat difficult because, as for me even though using the same operating system on rpi and my desktop computer, errors appeared at different spots. My solution was to simply fiddle around with the code and just trying random combination, leading me to success.
It is important that you use iwconfig to determine the name of your wifi dongle
Use these commands
ifconfig wlan0 down
airmon-ng check kill //Only useful in some situations
usermod -a -G netdev USERNAME //In case the operation is not permitted even though you are root
iwconfig wlan0 mode monitor //On RPi simply use this command without turning wlan0 down
ifconfig wlan0 up
iwconfig //Check out whether you have been successful and the mode says 'monitor' now
No idea why it does not always work the same way but your are very likely to succeed with the above commands.
Using Scapy
Finally, the fun stuff. Get ready to use pip to install scapy (python3 -m pip install scapy). Sadly, scapy only supports Python up to version 3.8, so make sure to have the correct version installed and activated as your default python. You also might need to run the script as root.
The code for sending packets is very straight forward:
from scapy.all import *
conf.use_pcap = True //Not quiet sure if this is optional
send(IP(dst="0.0.0.0")/UDP(dport=123, sport=200)/Raw(load="I am WIFI"), iface="wlan0", loop=1, inter=0.2)
I am not really trying to make a tutorial on how scapy itself works, only the big picture and how to set it up. It is a very interesting library and you should definitely check it out.
Most errors will arise from the import as it is crucial to use the proper python version! Also, the similar methods send() and sendp() troubled me a lot. I was unable to pick up anything with wireshark useing the sendp() method using the same parameters as above.
The iface="wlan0" is responsible for selecting the interface via which the packets are send. It should be matching with the interface you found earlier with the iwconfig command and set to monitor mode.
Using Wireshark
Wireshark is an awesome tool for prototyping whatever you want to do. If something is not working you should start looking there first. You can use it to identify what you are sending by running Wireshark on the transmitting wifi dongle or use another wifi dongle to pick up your packets. If you have done everything correctly and run the python script, while recording with Wireshark, you should be picking up many of the "I am WIFI" messages.
Thank you for going thorugh all of this. I hope I saved some people from all-nighters trying to figure out kernels, drivers or version mismatching.
Do ask me questions.

How to connect to a remote kernel in a ipynb file? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'd like to know how to use a remote AWS instance as the backend for my ipython notebook that I have running locally. I typically use nteract as the frontend for my jupyter notebook.
Motivation: is that my macbook doesn't have an Nvidia GPU, so I'd like the computations done on my P2 instance remotely, but with the notebook running locally.
This is my first question, so please be gentle :)
Typically you ssh to an AWS instance using something like
$ ssh -i key.pem username#ec2-198-51-100-1.compute-1.amazonaws.com
You can local forward to a port, say 8888, with
$ ssh -i key.pem -L 127.0.0.1:8888:127.0.0.1:8888 username#ec2-198-51-100-1.compute-1.amazonaws.com
This will forward anything running on localhost at port 8888 on your AWS instance, to localhost 8888 on your MacBook.
Then on your AWS instance, launch an ipython notebook
$ jupyter notebook --no-browser --port 8888
and then on your MacBook, open a browser and navigate to localhost:8888 and you'll be using the notebook from your AWS instance (which has GPU support).
Hope this helps.

Linux: Warn Python Script of Restart [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a Raspberry Pi which uses a USB wireless adapter and wicd-curses. A Python script runs in the background which uses a WebSocket. When I call sudo reboot, my Python script gets the signal to restart (with SIGTERM) about 20 seconds later. (I don't know why the computer takes 20 seconds to restart anyway. I don't remember it being this way before installing wicd-curses.)
By the time 20 seconds has passed, wicd-curses has already disconnected from the wireless network, meaning my Python script cannot properly close the WebSocket connection. So the core of my question is this: what Python commands are available to me to ensure that my script is notified of the system shutdown earlier than it is now? Is there any sort of event for which I can listen? Preferably, I want to be able to run the script on demand (python myscript.py) without the use of a daemon or service or whatever it might be called in the Linux world. Thank you.

Run python in terminal and don't terminate when terminal is closed [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I need to make static website. So I connected via ssh to some local server, where I want to make a static website. Then I used python to make it work:
$ python -m http.server 55550
But if I close terminal, then python program is terminated. I want to shut down my computer, but I want to let this process running on that local server, so other people could still access that website.
How can I do this? After that, how should I terminate that process later?
Thanks for any help
Use the nohup shell builtin:
nohup python -m http.server 55550
To terminate the process, simply kill it using the kill command, just like any other process.
you can also launch it in background
python -m http.server 55550 &
then enter
disown
to detach the process to the current term
screen
python -m SimpleHTTPServer 55550 &
press ctrl+a, then press d
exit
shutdown your computer
...
start your computer
ssh your server
screen -r

Categories