bash

Python sockets/port forwarding

℡╲_俬逩灬. 提交于 2021-02-06 12:57:09
问题 I've written server and client programs with python Server.py import socket sock = socket.socket (socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostname() port = 5555 sock.bind((host, port)) sock.listen(1) conn, addr = sock.accept() data = "Hello!" data = bytes(data, 'utf-8') conn.send(data) sock.close() Client.py on linux import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostname() port = 5555 sock.connect((host, port)) data = sock.recv(2048) data

How to set ANT_HOME on Ubuntu Desktop 12.04?

﹥>﹥吖頭↗ 提交于 2021-02-06 11:38:09
问题 It looks like Ubuntu uses ~/.bashrc , ~/.bash_profile , ~/.pam_profile , /etc/environment , and /etc/profile in very similar ways. I'd like to be able to add a configuration to one of these (which ever is the appropriate one) to set ANT_HOME to be the absolute path to my Ant installation's root directory (happens to be /opt/apache/ant/1.8.4/apache-ant-1.8.4/ ). This variable needs to be "honored" as is any normal env var, where I can open up a terminal and echo it at any time. It would also

Root access for Jupyter/iPython Notebook

落花浮王杯 提交于 2021-02-06 10:13:52
问题 I'm trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself. I've tried $ sudo jupyter notebook to run the notebook as root, but that only returns: $ jupyter: 'notebook' is not a Jupyter command So, I'm left with running $ jupyter notebook (unless there's a way to run Jupyter notebook as root). I also can't do su root in the notebook itself because that requires an input and the notebook won't let me give an input. Finally, there is

Root access for Jupyter/iPython Notebook

北慕城南 提交于 2021-02-06 10:12:24
问题 I'm trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself. I've tried $ sudo jupyter notebook to run the notebook as root, but that only returns: $ jupyter: 'notebook' is not a Jupyter command So, I'm left with running $ jupyter notebook (unless there's a way to run Jupyter notebook as root). I also can't do su root in the notebook itself because that requires an input and the notebook won't let me give an input. Finally, there is

grep output into array

梦想的初衷 提交于 2021-02-06 09:01:52
问题 Guys How can I make this work `find /xyz/abc/music/ |grep def` I don't want to store the array in any temporary variable. How can we directly operate on this array. so to get the 1st element of that array echo ${$(`find /xyz/abc/music/ |grep def`)[0]} Please help me How I can achieve this 回答1: If you just need the first element (or rather line), you can use head : `find /xyz/abc/music/ |grep def | head -n 1` If you need access to arbitrary elements, you can store the array first, and then

grep output into array

跟風遠走 提交于 2021-02-06 09:01:30
问题 Guys How can I make this work `find /xyz/abc/music/ |grep def` I don't want to store the array in any temporary variable. How can we directly operate on this array. so to get the 1st element of that array echo ${$(`find /xyz/abc/music/ |grep def`)[0]} Please help me How I can achieve this 回答1: If you just need the first element (or rather line), you can use head : `find /xyz/abc/music/ |grep def | head -n 1` If you need access to arbitrary elements, you can store the array first, and then

grep output into array

心不动则不痛 提交于 2021-02-06 09:01:02
问题 Guys How can I make this work `find /xyz/abc/music/ |grep def` I don't want to store the array in any temporary variable. How can we directly operate on this array. so to get the 1st element of that array echo ${$(`find /xyz/abc/music/ |grep def`)[0]} Please help me How I can achieve this 回答1: If you just need the first element (or rather line), you can use head : `find /xyz/abc/music/ |grep def | head -n 1` If you need access to arbitrary elements, you can store the array first, and then

ERROR: ld.so: object LD_PRELOAD cannot be preloaded: ignored

醉酒当歌 提交于 2021-02-06 06:36:04
问题 I am using ubuntu 12.04. Every time I start my bash terminal and every time when I finish typing a command(and press enter) , I get this message: ERROR: ld.so: object '/usr/lib/liblunar-calendar-preload.so' from LD_PRELOAD cannot be preloaded: ignored. It is weird. So what is the environment variable LD_PRELOAD used for? And what is the going on behind the scene? Thanks. 回答1: The linker takes some environment variables into account. one is LD_PRELOAD from man 8 ld-linux : LD_PRELOAD A

ERROR: ld.so: object LD_PRELOAD cannot be preloaded: ignored

余生颓废 提交于 2021-02-06 06:35:19
问题 I am using ubuntu 12.04. Every time I start my bash terminal and every time when I finish typing a command(and press enter) , I get this message: ERROR: ld.so: object '/usr/lib/liblunar-calendar-preload.so' from LD_PRELOAD cannot be preloaded: ignored. It is weird. So what is the environment variable LD_PRELOAD used for? And what is the going on behind the scene? Thanks. 回答1: The linker takes some environment variables into account. one is LD_PRELOAD from man 8 ld-linux : LD_PRELOAD A

Linux Bash: Move multiple different files into same directory

笑着哭i 提交于 2021-02-06 02:29:05
问题 As a rather novice Linux user, I can't seem to find how to do this. I am trying to move unique files all in one directory into another directory. Example: $ ls vehicle car.txt bicycle.txt airplane.html train.docx (more files) I want car.txt, bicycle.txt, airplane.html, and train.docx inside vehicle. Right now I do this by moving the files individually: $ mv car.txt vehicle $ mv bicycle.txt vehicle ... How can I do this in one line? 回答1: You can do mv car.txt bicycle.txt vehicle/ (Note that