command

C#: get external shell command result line by line

天大地大妈咪最大 提交于 2021-02-07 03:31:33
问题 I am writing a C# winform application that starts a second process to execute shell commands like "dir" and "ping". I redirect the second process's output so my app can receive the command result. It roughly works fine. The only problem is my winform app receives the command line output as a whole instead of line by line. For example, it has to wait for the external "ping" command to finish (which takes many seconds or longer) and then receives the whole output (many lines) at once. What I

Quick ls command

旧街凉风 提交于 2021-02-05 20:12:21
问题 I've got to get a directory listing that contains about 2 million files, but when I do an ls command on it nothing comes back. I've waited 3 hours. I've tried ls | tee directory.txt , but that seems to hang forever. I assume the server is doing a lot of inode sorting. Is there any way to speed up the ls command to just get a directory listing of filenames? I don't care about size, dates, permission or the like at this time. 回答1: ls -U will do the ls without sorting. 回答2: Try using: find .

create unix alias using a python3 script

爷,独闯天下 提交于 2021-02-05 09:11:45
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,

create unix alias using a python3 script

好久不见. 提交于 2021-02-05 09:11:23
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,

create unix alias using a python3 script

百般思念 提交于 2021-02-05 09:06:09
问题 Well, as we all known, creating an alias in a terminal shell is quite easy: ZZ:~ zhangzhao$ alias c='uname' ZZ:~ zhangzhao$ c Darwin ZZ:~ zhangzhao$ But now I want to do the same thing through a Python3 script. I've checked the ref manual and found these sort of command work can be solved using subprocess module. Then I write the script below: import subprocess subprocess.call(["alias", "c=\'uname\'"]) But note that this operation will not take effect to the shell you are currently using,

Pass command line argument to python script [duplicate]

孤人 提交于 2021-02-04 21:09:50
问题 This question already has answers here : How to read/process command line arguments? (18 answers) Closed 2 years ago . I have a file.py that I want to pass base_url to when called, so that base_url variable value can be dynamic upon running python file.py base_url='http://google.com' the value of http://google.com could then be used directly in the execution of file.py. How might I go about doing this? Thanks 回答1: The command line arguments are stored in the list sys.argv . sys.argv[0] is the

Pass command line argument to python script [duplicate]

↘锁芯ラ 提交于 2021-02-04 21:08:18
问题 This question already has answers here : How to read/process command line arguments? (18 answers) Closed 2 years ago . I have a file.py that I want to pass base_url to when called, so that base_url variable value can be dynamic upon running python file.py base_url='http://google.com' the value of http://google.com could then be used directly in the execution of file.py. How might I go about doing this? Thanks 回答1: The command line arguments are stored in the list sys.argv . sys.argv[0] is the

Windows下Cygwin 的安装

早过忘川 提交于 2021-02-02 02:54:51
在安装时, 单击加号 (+) 展开对应的类别;单击 “循环” 标志在 Skip(忽略此包)和包的所有可用版本之间循环。如果 Cygwin 提供一个实用程序的多个版本,应该选择满足您的需求的实例。顺便说一下,如果选择 B 列,就会下载二进制包;选择 S,也会下载源代码。 我用的windows xp系统,安装完Cygwin之后,点击图标,出现cygiconv-2.dll找不到的错误。 在网上下载一个 cygiconv-2.dll组件之后,并把它放入C:\WINDOWS\system32目录下。然后就OK了。 在安装完Cygwin 之后,点击Cygwin,输入基本命令ls等,出现Command not found。 原因是没有设置环境变量。 只需将Cygwin.bat文件修改为: @echo off set CYGWIN=tty notitle glob set PATH=%PATH%;d:/cygwin/bin;d:/cygwin/sbin;d:/cygwin/usr/bin;d:/cygwin/usr/sbin;d:/cygwin/usr/local/bin set LD_LIBRARY_PATH=d:/cygwin/lib;d:/cygwin/usr/lib;d:/cygwin/usr/local/lib d: chdir d:\cygwin\bin bash --login -i

How do I print the current working directory of another user in linux?

为君一笑 提交于 2021-01-29 16:13:39
问题 Is there a command line I can issue to see what directory another user is currently working in? This would be like using >pwd but for the other user. 回答1: There's a cwd symlink in every process' /proc folder, but as a commoner you wouldn't have any rights to read any other's proc folder - only your own: [marc@panic home]$ ls -l /proc/$$/cwd lrwxrwxrwx. 1 marc marc 0 May 5 12:06 /proc/16257/cwd -> /home ^^^^^---cwd [marc@panic home]$ ^^^^---cwd 来源: https://stackoverflow.com/questions/23478833

No Command responses using Discord.py Rewrite [duplicate]

不想你离开。 提交于 2021-01-29 10:20:20
问题 This question already has an answer here : Why does on_message stop commands from working? (1 answer) Closed 12 months ago . I have created a discord bot using the code below but when I type .8ball or .ping in the server, I get no response, nor do I get an error message of any kind. However, I do get the expected response of "Hi" when I type "hello" so I know it's connected. It's baffling me as I've checked the syntax 100 times and can't see any errors. import discord import random from