test.py:

#coding=utf-
import subprocess
compilePopen = subprocess.Popen('gcc haha',shell=True,stderr=subprocess.PIPE)
compilePopen.wait()
print('the status code is:',compilePopen.returncode)
with open('log','w') as object:
object.write(compilePopen.stderr.read())

test.sh:

#!/bin/bash
while read str; do
echo $str
done <readme.txt
sudo chmod +x test.sh
./test.sh

输出:

#coding=utf-
import subprocess
compilePopen = subprocess.Popen('gcc haha',shell=True,stderr=subprocess.PIPE)
compilePopen.wait()
print('the status code is:',compilePopen.returncode)
with open('log','w') as object:
object.write(compilePopen.stderr.read())

shell 按行读取文件的内容的更多相关文章

  1. Shell按行读取文件的3种方法

    Shell按行读取文件的方法有很多,常见的三种方法如下: 要读取的文件: [root@mini05 -]# cat file.info 写法一: [root@mini05 -]# cat read1. ...

  2. shell按行读取文件

    这工作小半年了发现以前学的那么多流弊技能都不怎么用,倒是shell用的很多,自己已经从shell小菜鸟一步步走过来,已经要变成大菜鸟=.= 经常需要用shell按行读取配置文件,自己在上面踩了很多坑, ...

  3. shell 按行读取文件

    #!/bin/bash count= //赋值语句,不加空格 cat test | while read line //cat 命令的输出作为read命令的输入,read读到的值放在line中 do ...

  4. C++/Php/Python/Shell 程序按行读取文件或者控制台

    写程序经常需要用到从文件或者标准输入中按行读取信息,这里汇总一下.方便使用 1. C++ 读取文件 #include<stdio.h> #include<string.h> i ...

  5. C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结。

    C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结. 一.总结 C++/Php/Python/Shell 程序按行读取文件或者控制台(php读取标准输入:$fp = fope ...

  6. shell总结:读取文件、参数、if、分割字符串、数组长度、空文件、变量赋值、多进程、按行切割文件、查看线程

    Reference: http://saiyaren.iteye.com/blog/1943207 1.     Shell  读取文件和写文件 for line in $(<top30000. ...

  7. Python跳过第一行读取文件内容

    Python编程时,经常需要跳过第一行读取文件内容.比较容易想到是为每行设置一个line_num,然后判断line_num是否为1,如果不等于1,则进行读取操作.相应的Python代码如下: inpu ...

  8. android按行读取文件内容的几个方法

    一.简单版 import java.io.FileInputStream; void readFileOnLine(){ String strFileName = "Filename.txt ...

  9. shell脚本,按行读取文件的几种方法。

    第一种方法用while实现按读取文件.[root@localhost wyb]# cat a.txt 第一行 aaaaaa 第二行 bbbbbb 第三行 cccccc 第四行 dddddd 第五行 e ...

随机推荐

  1. Oracle SQL 部分特殊字符转义及escape的用法

    在处理sql时,遇到insert 或update 的参数中含有特殊字符“&”,下划线“_”, 单引号" ' "等时,要做转义处理. 例:插入特殊字元'&' upda ...

  2. Summary: Calculate average where sum exceed double limits

    What is a good solution for calculating an average where the sum of all values exceeds a double's li ...

  3. es6 遍历总结

    1.for in / for of for in --> index是key值 var array = [1,2,3,4,5]; for(let index in array) { consol ...

  4. web自动化测试python+selenium学习总结----selenium安装、浏览器驱动下载

    一.安装selenium 命令安装selenium库 :pip  install -U selenium 查看selenium是否安装成功:pip list PS:有时会有异常,安装失败,可以尝试去s ...

  5. 安装Oracle Grid的过程中用到的几个小技巧

    1.利用文件来模拟块设备 在grid的安装教程中有一步是 provision the disk devices for use with ASM Filter Driver.但是如果我们没有多个磁盘怎 ...

  6. [批处理]使用Log.io监控日志变化

    背景 多台服务器安装了不同的开发服务,增加日志监控以随时处理情况 方案 log.io 环境 NodeJs 安装 1.log.io直接无法安装上,使用log.io-ts安装上 npm install - ...

  7. Caravel–一款开源OLAP+数据可视化分析前端工具,支持Druid和Kylin

    参考此文:http://lxw1234.com/archives/2016/06/681.htm

  8. 简单快速部署nexus3私服

    本文适用范围:用户规模不大,不需要考虑maven仓库负载均衡的群体. 为何部署nexus3 之前由于懒某些原因,所有开发人员自己定义.m2的settings,大多使用ali提供的maven仓库,但是最 ...

  9. IIS + FastCGI+php(从5.2升级到5.3)

    由于PHP5.3 的改进,原有的IIS 通过isapi 方式解析PHP脚本已经不被支持,PHP从5.3.0 以后的版本开始使用微软的 fastcgi 模式,这是一个更先进的方式,运行速度更快,更稳定. ...

  10. AI时代学习新的技术,方向为计算机视觉--欢迎来我的简书blog拔草

    2017-09-01 19:29:33 简书blog: https://www.jianshu.com/u/973c8c406de7