Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1789910
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: WINDOWS

2016-10-24 19:52:38

最近在windows 上装了curl 和 freesshd 把windows 当Linux用,不亦乐乎,记录下这几天的心得。
下载windows curl 的地址: 看来就是URL里面传了几个参数而已。
https://curl.haxx.se/dlwiz/?type=bin&os=Win64&flav=-&ver=*&cpu=x86_64

1.   根据字符串查询进程

点击(此处)折叠或打开

  1. 相当于linux 下的ps -ef |grep -i java 
  2. tasklist |findstr /I java
  3. 其实findstr 很复杂, 请看
  4. C:\Users\Administrator>findstr -?
    Searches for strings in files.


    FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
            [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
            strings [[drive:][path]filename[ ...]]


      /B         Matches pattern if at the beginning of a line.
      /E         Matches pattern if at the end of a line.
      /L         Uses search strings literally.
      /R         Uses search strings as regular expressions.
      /S         Searches for matching files in the current directory and all
                 subdirectories.
      /I         Specifies that the search is not to be case-sensitive.
      /X         Prints lines that match exactly.
      /V         Prints only lines that do not contain a match.
      /N         Prints the line number before each line that matches.
      /M         Prints only the filename if a file contains a match.
      /O         Prints character offset before each matching line.
      /P         Skip files with non-printable characters.
      /OFF[LINE] Do not skip files with offline attribute set.
      /A:attr    Specifies color attribute with two hex digits. See "color /?"
      /F:file    Reads file list from the specified file(/ stands for console).
      /C:string  Uses specified string as a literal search string.
      /G:file    Gets search strings from the specified file(/ stands for console).
      /D:dir     Search a semicolon delimited list of directories
      strings    Text to be searched for.
      [drive:][path]filename
                 Specifies a file or files to search.


    Use spaces to separate multiple search strings unless the argument is prefixed
    with /C.  For example, 'FINDSTR "hello there" x.y' searches for "hello" or
    "there" in file x.y.  'FINDSTR /C:"hello there" x.y' searches for
    "hello there" in file x.y.


    Regular expression quick reference:
      .        Wildcard: any character
      *        Repeat: zero or more occurrences of previous character or class
      ^        Line position: beginning of line
      $        Line position: end of line
      [class]  Character class: any one character in set
      [^class] Inverse class: any one character not in set
      [x-y]    Range: any characters within the specified range
      \x       Escape: literal use of metacharacter x
      \   xyz\>    Word position: end of word


    For full information on FINDSTR regular expressions refer to the online Command
    Reference.


看起来windows 下的find 和findstr 也不弱啊。

点击(此处)折叠或打开

  1. C:\Users\Administrator>help find
  2. Searches for a text string in a file or files.

  3. FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

  4.   /V Displays all lines NOT containing the specified string.
  5.   /C Displays only the count of lines containing the string.
  6.   /N Displays line numbers with the displayed lines.
  7.   /I Ignores the case of characters when searching for the string.
  8.   /OFF[LINE] Do not skip files with offline attribute set.
  9.   "string" Specifies the text string to find.
  10.   [drive:][path]filename
  11.              Specifies a file or files to search.

  12. If a path is not specified, FIND searches the text typed at the prompt
  13. or piped from another command.
2.  重定向。

点击(此处)折叠或打开

  1. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version
  2. #相当于
  3. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version >con 2>con 
  4. #这个命令的输出吓了我一跳,原来java.exe -version 的输出居然是stderror.
  5. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version >NUL
  6. #2>nul 就可以将stderr 重定向到nul, 就是Linux 上的2 >/dev/null. 
  7. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version 2>NUL
  8. #来个比较正常的重定向:
  9. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version >1.txt 
  10. #下面来重定向两个文件
  11. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version >3.txt 2>&1
  12. "c:\Program Files\IBM\Director\jre\bin\java.exe" -version 2>4.txt
  13. #打印下txt文本的内容
  14. type 4.txt
  15. #比较下两个文本的异同,有点像linux 下的diff 
  16. C:\Users\Administrator>fc 4.txt 3.txt
  17. Comparing files 4.txt and 3.TXT
  18. FC: no differences encountered
  19. #最后查看上一条命令的返回值,就是linux下的echo $?
  20. echo %ERRORLEVEL%
  21. #但是在bat脚本里面就不能这么用,要参考这个https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/setlocal.mspx?mfr=true

3. 在windows 上安装freesshd ,然后通过paramiko 在windows 上执行命令,碰到了很多次这个错误。

点击(此处)折叠或打开

  1. Output: Unable to execute command or shell on remote system: Failed to Execute process
经过搜索下得知:要在命令前加上"cmd /c"

点击(此处)折叠或打开

  1. 例如我在windows 上通过curl 下载的命令是这样:
  2. r"curl -o c:\{0} -s -k -u {1}:{2} {3}".format(filename, user,pass,url)
  3. 改成:
  4. r"cmd /c curl -o c:\{0} -s -k -u {1}:{2} {3}".format(filename, user,pass,url)

阅读(1483) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~