由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - [请教]命令行的重定向
相关主题
请教一个C++的设计问题一个弱问题,关于打开HTTP文件
问一个python打包的问题为什么在DLL code里不能cout或者printf ?
strange behavior about chmod 777 -R (转载)pollsys 是干嘛的?
perl question问问跟Linux Kernel Programming 有关的问题
问一个Mandriva 2007 下Tix的问题Help: undefined symbol
问个socket编程中select()的问题。One more "keng" about Perl
does the system guarantee this? (转载)python和java里面非memory资源怎么回收?
A question related to pipepython的shell
相关话题的讨论汇总
话题: folder话题: 重定向话题: output话题: exec话题: 命令行
进入Programming版参与讨论
1 (共1页)
l******t
发帖数: 12659
1
向大家请教一个问题:
1. 编译文件: g++ -o exec prog.cpp
2. 重定向: exec < folder > output
目的是打算从folder里面寻找所需要的文件,然后处理后,将结果保存到output
请问,我在主程序中,如何得到folder的名字;里面的文件等信息啊?
多谢了!
X****r
发帖数: 3557
2
Redirection does not work like this. Redirecting input of a program
from a file means that the standard input (file descriptor 0, which
corresponds to stdin in C or cin in C++) would be from this file
instead of from a console (where you type). However, directory
is a special kind of file so it probably wouldn't work for you here.
If your program can read the list of files from standard input and
examine them, you can do
(assuming . is in your path, otherwise you need to use ./prog)
g++ -o prog

【在 l******t 的大作中提到】
: 向大家请教一个问题:
: 1. 编译文件: g++ -o exec prog.cpp
: 2. 重定向: exec < folder > output
: 目的是打算从folder里面寻找所需要的文件,然后处理后,将结果保存到output
: 请问,我在主程序中,如何得到folder的名字;里面的文件等信息啊?
: 多谢了!

c*m
发帖数: 1114
3
Redirection is not appropriate here.
It should like "exec foldername outputfilename".
And you may use to access files inside the specific folder(opendi
r or whatever). And finally write output to "outputfilename".
Check this thread
http://www.linuxquestions.org/questions/programming-9/c-list-files-in-direct
ory-379323/
BTW, if you have to use "< folder" and ">output", you may read folder name
as a string and do the same thing on above.

【在 l******t 的大作中提到】
: 向大家请教一个问题:
: 1. 编译文件: g++ -o exec prog.cpp
: 2. 重定向: exec < folder > output
: 目的是打算从folder里面寻找所需要的文件,然后处理后,将结果保存到output
: 请问,我在主程序中,如何得到folder的名字;里面的文件等信息啊?
: 多谢了!

l******t
发帖数: 12659
4
非常感谢两位的回复!!!
我也不知道为什么那个题目重定向stdin到文件夹
不过, wc的命令似乎也可以将stdin重定向到文件夹
link: http://blog.chinaunix.net/u1/56343/showart_442411.html
1 (共1页)
进入Programming版参与讨论
相关主题
python的shell问一个Mandriva 2007 下Tix的问题
想实现一个简单的script language,用perl好做么?问个socket编程中select()的问题。
[合集] 请教一个Linux系统编程的问题does the system guarantee this? (转载)
[合集] 我也花了一小时读了一下pythonA question related to pipe
请教一个C++的设计问题一个弱问题,关于打开HTTP文件
问一个python打包的问题为什么在DLL code里不能cout或者printf ?
strange behavior about chmod 777 -R (转载)pollsys 是干嘛的?
perl question问问跟Linux Kernel Programming 有关的问题
相关话题的讨论汇总
话题: folder话题: 重定向话题: output话题: exec话题: 命令行