terminal

Node.js: How to send control C to child process

让人想犯罪 __ 提交于 2019-12-12 02:08:39
问题 I am writing one web-like linux shell using node.js + socket.io. Simple command like, ls, cd are working well. But when issue command like ping google.com, the stdout is printing endlessly. I tried to send Ctrl +C to stdin, but no luck. 1) spawn 'bash' process spawn = require('child_process').spawn; var sh = spawn('bash'); 2) send bash stdout to socket.io sh.stdout.on('data', function(data) { console.log('stdout' + data); listener.sockets.emit("stdout",new Buffer(data)); }); 3) Sending Ctl C

How to use SimpleHTTPServer?

流过昼夜 提交于 2019-12-12 02:07:48
问题 I'm trying to start a simple http server with the most recent version of Python 2.7. I'm following a tutorial and it instructs me to do the following: Open the Terminal then navigate to our client directory and enter the following command: $ python -m SimpleHTTPServer But no matter what I've tried, including other codes, it doesn't work. Can anyone help please? It always puts a syntax error such as: '$' is not recognized as an internal or external command, operable program or batch file. If I

How can I run CasperJS files in Android?

≡放荡痞女 提交于 2019-12-12 02:05:34
问题 How can I install and run CasperJS files in Android? Is it possible? I would like to create an equal application droidscript with test functions and execute on a webview. 回答1: CasperJS is built on top of PhantomJS (and SlimerJS). Those are browsers themselves. They cannot be run in a WebView. It may be possible to compile, though I didn't find any documented trials. You should be able to port the PhantomJS API to an Android WebView and then make some adjustments to CasperJS so that it uses

Change the name of many files

孤街醉人 提交于 2019-12-12 01:57:16
问题 How can I rename many files. Remove the digits at the beginning. I have a Mac. All the files are in the same folder. The pattern is: 1, 2 or 3 digits - any name.php With Regular Expression, I think it would be: \d*-(.*).php For example: 1-marketing.php 2-3D.php 3-without.php I want to remove the numbers and the dash at the beginning. In the example it would be: marketing.php 3D.php without.php What I have explored two ways: Select the files > ctrl click > rename items. This is a fantastic

Open an lxterminal window via shell script triggered by udev rule

て烟熏妆下的殇ゞ 提交于 2019-12-12 01:45:25
问题 I'm trying to start a python script that waits for user input via a shell script triggered by a UDEV rule . After the input arrives the python script needs to make some database calls. I'm running into a couple different issues. Here is the udev rule: SUBSYSTEM=="usb" RUN+="/path/to/script.sh" Issue #1 - I can't seem to get it to actually open the window. Here is what I have in script.sh: #!/bin/bash lxterminal -e /path/to/python_script.py Here is the error I'm getting from udev: '/path/to

error when compiling java program 'Cannot find symbol'

本小妞迷上赌 提交于 2019-12-12 01:45:15
问题 I get these errors when trying to compile 'PongMain.java' with the javac -g command in terminal: Errors: tests-iMac:~ finnfallowfield$ javac -g /Users/finnfallowfield/Desktop/Developer/Java\:Javascript/Game\ Development/Java\ Pong/src/main/pong/PongMain.java /Users/finnfallowfield/Desktop/Developer/Java:Javascript/Game Development/Java Pong/src/main/pong/PongMain.java:9: error: cannot find symbol import main.pong.Ball; ^ symbol: class Ball location: package main.pong /Users/finnfallowfield

How can I specify a particular user-agent string in a command-line invocation of Firefox?

大兔子大兔子 提交于 2019-12-12 01:29:14
问题 I would like to make a bash script that will iterate over different user agent options, open Firefox with the selected user agent, wait for x seconds, and then close, and loop. Is there a command-line option for firefox to specify the user agent? 回答1: There is no flag for this specific purpose, but you can create a set of Firefox profiles, where each profile will specify a particular user agent. There is an about:config option general.useragent.override, which you can specify in the user.js

Real-time reading of terminal output from server

雨燕双飞 提交于 2019-12-12 01:24:43
问题 I'm trying to process images from my camera on my server and get the information after processing on my local machine in real-time. I can get necessary information as terminal outputs on my server, but I can't put this info in my python code on local machine, until my server program is running. I'm tried this code: cmd="sshpass -p 'pass' ssh -Y user@ip -t 'process_image; bash -l'" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1) for line in iter(p.stdout.readline, b''): print(line

Exception in thread “main” java.lang.UnsatisfiedLinkError: no Terminal in java.library.path

北城余情 提交于 2019-12-12 01:23:02
问题 I was trying to run the CHARVA Tutorial thru Eclipse after setting up the JAR, but I receive Exception in thread "main" java.lang.UnsatisfiedLinkError: no Terminal in java.library.path in the console. Any clue on how to fix this up? 回答1: As Dave said, Charva requires a native library called Terminal to run. As far as I remember, it is included in the binary distribution for Charva. Eclipse-specific instructions: In your project properties, select Java Build Path, then Libraries. Locate the

Output not displayed with usleep until a line break is given

耗尽温柔 提交于 2019-12-12 01:08:26
问题 I'm trying to program a simple "typewriter" effect in C, where text appears one letter at a time with a delay. Here's the function I have: #include <stdio.h> #include <unistd.h> void typestring(const char *str, useconds_t delay) { while (*str) { putchar(*(str++)); usleep(delay); } } The problem is the text doesn't actually appear until a \n is displayed. What am I doing wrong? 回答1: The output to stdout is buffered. Using \n you are forcing a flush. If you want to change this, you will need to