shell

Issuing commands to psuedo shells (pty)

元气小坏坏 提交于 2021-02-04 21:34:22
问题 I've tried to use the subprocess, popen, os.spawn to get a process running, but it seems as though a pseudo terminal is needed. import pty (master, slave) = pty.openpty() os.write(master, "ls -l") Should send "ls -l" to the slave tty... I tried to read the response os.read(master, 1024), but nothing was available. EDIT: Also tried to create pty's, then open the call in a subprocess -- still didn't work. import pty import subprocess (master, slave) = os.openpty() p = subprocess.Popen("ls",

SCP says file has downloaded, but the file does not appear

 ̄綄美尐妖づ 提交于 2021-02-04 19:41:45
问题 I am using ssh to work on a remote server, however when I try to download a file using scp in this format: scp name@website.com:somefile.zip ~/Desktop It asks me for my password, and shows this: somefile.zip 100% 6491 6.3KB/s 00:00 however, this file never appears on my desktop. Any help 回答1: I think that you are logging into the remote machine using ssh and then running the command on the remote machine. You should actually be running the command without logging into your remote server first

SCP says file has downloaded, but the file does not appear

不羁的心 提交于 2021-02-04 19:39:06
问题 I am using ssh to work on a remote server, however when I try to download a file using scp in this format: scp name@website.com:somefile.zip ~/Desktop It asks me for my password, and shows this: somefile.zip 100% 6491 6.3KB/s 00:00 however, this file never appears on my desktop. Any help 回答1: I think that you are logging into the remote machine using ssh and then running the command on the remote machine. You should actually be running the command without logging into your remote server first

Handling interactive shells with Python subprocess

∥☆過路亽.° 提交于 2021-02-04 19:31:12
问题 I am trying to run multiple instances of a console-based game (dungeon crawl stone soup -- for research purposes naturally) using a multiprocessing pool to evaluate each run. In the past when I've used a pool to evaluate similar code (genetic algorithms), I've used subprocess.call to split off each process. However, with dcss being quite interactive having a shared subshell seems to be problematic. I have the code I normally use for this kind of thing, with crawl replacing other applications

Get Monday and Sunday etc.. for a week for any date as parameter in Unix

吃可爱长大的小学妹 提交于 2021-02-04 18:40:09
问题 How to get the date of Monday and Sunday in a week for a date? This gives date for 'last' monday: date -dlast-monday +%Y%m%d I want to pass a date as parameter to find the Monday and Sunday for that week. Basically, I want to get Sunday and Monday for a week, for ANY date, NOT only for last monday . 回答1: Try this: export day=2013-10-01 date -d "$day -$(date -d $day +%w) days" This will always print the Sunday before the given date (or the date itself). date -d "$day -$(date -d $day +%u) days"

FFMPEG Crop with side by side merge

我只是一个虾纸丫 提交于 2021-02-04 15:59:05
问题 I am trying to create a shell/ffmpeg script that can show multiple files after they have been processed using different filters in a side by side / tiled way. An example of desired output would be: https://www.youtube.com/watch?v=DoPuhMRYem4. In order to create the desired output I need to crop off the right half of video1 and the left half of video2 and then join them back with [video1+video2] side by side. I have played around with a bunch of different ways of joining them, this does OK:

How to assign a multiple line value to a bash variable

大城市里の小女人 提交于 2021-02-04 14:39:48
问题 I have a variable FOO with me that needs to be assigned with a value that will be multiple lines. Something like this, FOO="This is line 1 This is line 2 This is line 3" So when I print the value of FOO it should give the following output. echo $FOO output: This is line 1 This is line 2 This is line 3 Furthermore, the number of lines will be decided dynamically as I will initialize it using a loop. The answers that have been shown in the other question using mainly read -d is not suitable for

Bash — find a list of files with more than 3 lines

我们两清 提交于 2021-02-04 13:17:05
问题 I have a directory of files and I want to find a list of files who has more than 2 lines. I know I can use wc -l to test each file, but how do I wrap it up in bash? Sorry for the newbie question, new to bash. 回答1: You can use this find command: find . -type f -exec bash -c '[[ $(wc -l < "$1") -gt 2 ]] && echo "$1"' _ '{}' \; 回答2: Using xargs and awk : $ find . -type f | xargs wc -l | awk '$1 > 2' If you are in a git repositiory and want to count only tracked files, you can use following

What does “< <(command args)” mean in the shell?

痴心易碎 提交于 2021-02-04 09:43:55
问题 When looping recursively through folders with files containing spaces the shell script I use is of this form, copied from the internet: while IFS= read -r -d $'\0' file; do dosomethingwith "$file" # do something with each file done < <(find /bar -name *foo* -print0) I think I understand the IFS bit, but I don't understand what the ' < <(...) ' characters mean. Obviously there's some sort of piping going on here. It's very hard to Google "< <", you see. 回答1: <() is called process substitution

What does “< <(command args)” mean in the shell?

会有一股神秘感。 提交于 2021-02-04 09:43:47
问题 When looping recursively through folders with files containing spaces the shell script I use is of this form, copied from the internet: while IFS= read -r -d $'\0' file; do dosomethingwith "$file" # do something with each file done < <(find /bar -name *foo* -print0) I think I understand the IFS bit, but I don't understand what the ' < <(...) ' characters mean. Obviously there's some sort of piping going on here. It's very hard to Google "< <", you see. 回答1: <() is called process substitution