如何将系统命令输出存储在变量中? [英] How to store the system command output in a variable?

查看:67
本文介绍了如何将系统命令输出存储在变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行一个system()函数,该函数返回一个文件名.现在,我不想在屏幕上显示输出(即文件名)或管道到新文件.我只想将其存储在变量中.那可能吗?如果是这样,怎么办?谢谢

I am executing a system() function which returns me a file name. Now I dont want to display the output on the screen(ie the filename) or pipe to a newfile. I just want to store it in a variable. is that possible? if so, how? thanks

推荐答案

单个文件名?是的.当然可以,但是不能使用 system().

A single filename? Yes. That is certainly possible, but not using system().

使用 popen() .在

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆