由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - [请教]文件输入 (转载)
相关主题
[Solved] Ubuntu 8.10安装在外置USB硬盘的问题怎样保证隐私?
弱问:如何copy目录下的所有文件到另外一个目录下?100伪币答谢Linux/Unix编程问题
How to find and delete all hard links to a file (ZZ)linux如何生成可执行文件?
gvim diff question如何把linux命令(多条)打包成可执行文件?(新手)
比较两个文件,把相同的行删除问个基础问题,关于linux command存放地址
请教:如何用sed来改变文件中的数字求教:服务器单cpu竟然比我笔记本的cpu算的还慢?
问个关于user/group的粗浅问题请教个文件权限的问题
比较二进制文件How to debug "broken pipe" in linux programming ?
相关话题的讨论汇总
话题: exe话题: file话题: fd话题: file1话题: data
进入Linux版参与讨论
1 (共1页)
a******k
发帖数: 1190
1
【 以下文字转载自 Programming 讨论区 】
发信人: aablackk (black), 信区: Programming
标 题: [请教]文件输入
发信站: BBS 未名空间站 (Fri May 29 16:20:42 2009)
我需要在一个perl程序里面调用一个可执行文件
这个可执行文件使用数据文件作为输入
我有数据,
但是因为我不想把这些数据写到文件里面,再使用文件进行输入,
而想直接把这些数据传递给这个可执行文件
请问有没有什么办法?
m*********g
发帖数: 273
2
if data.dat is your data and exe is your executable file,
then in perl `exe data.da`. Is this your problem?
a******k
发帖数: 1190
3
no, data is generated on the fly,
i do not want to write them onto hard disk as data.dat
and want to supply them directly to exe
m*********g
发帖数: 273
4
Can you change exe?

【在 a******k 的大作中提到】
: no, data is generated on the fly,
: i do not want to write them onto hard disk as data.dat
: and want to supply them directly to exe

a******k
发帖数: 1190
5
no

【在 m*********g 的大作中提到】
: Can you change exe?
R****a
发帖数: 199
6
Can you take something like the following:
yourownexecutable data1 data2 data3 ....
I guess that is not a good solution for you if you have too many data items.
But this does satisfy your request.

【在 a******k 的大作中提到】
: no, data is generated on the fly,
: i do not want to write them onto hard disk as data.dat
: and want to supply them directly to exe

m**********g
发帖数: 434
7
questions:
1) can you make a c file/header to access that data file?
2) can you use perl to run that c file/header?

【在 a******k 的大作中提到】
: no
w********e
发帖数: 557
8
If exe can't changed then it is hard. Maybe you can use pipe to pass the
results to exe.
If exe can be changed, you can make exe wait for the results.
a******k
发帖数: 1190
9
thanks, i realised that maybe i need my own exe

items.

【在 R****a 的大作中提到】
: Can you take something like the following:
: yourownexecutable data1 data2 data3 ....
: I guess that is not a good solution for you if you have too many data items.
: But this does satisfy your request.

a******k
发帖数: 1190
10
there is no data file
data generated on the fly
i just do not want to put data into a file

【在 m**********g 的大作中提到】
: questions:
: 1) can you make a c file/header to access that data file?
: 2) can you use perl to run that c file/header?

a******k
发帖数: 1190
11
i was thinking piping, but no idea
probably i should program my own exe

【在 w********e 的大作中提到】
: If exe can't changed then it is hard. Maybe you can use pipe to pass the
: results to exe.
: If exe can be changed, you can make exe wait for the results.

p*****s
发帖数: 344
12
it all depends what ur exe read from.
if it takes a command option as filename and then open a file descriptor.
I am thinking maybe the parent process can overwrite the variable that
saves the fd. so that it can read from pipe.

【在 a******k 的大作中提到】
: i was thinking piping, but no idea
: probably i should program my own exe

a******k
发帖数: 1190
13
yes, it takes a command option to read file, like:
exe -i file1 -j file2 -other options
is it possible to call it without file in perl?

【在 p*****s 的大作中提到】
: it all depends what ur exe read from.
: if it takes a command option as filename and then open a file descriptor.
: I am thinking maybe the parent process can overwrite the variable that
: saves the fd. so that it can read from pipe.

p*****s
发帖数: 344
14
just some thoughts, never tried myself
1. you call "exe with -i file1 -j file2 ..." first. Assume the return
process id is , ls /proc//fd/
you should file some fd nums ( 2. by default /proc//1, 2, 3 are your pipe fd
3. use gdb attach to the process
4. use dup2(,) to swap fd so that your exe can read
from pipe

【在 a******k 的大作中提到】
: yes, it takes a command option to read file, like:
: exe -i file1 -j file2 -other options
: is it possible to call it without file in perl?

1 (共1页)
进入Linux版参与讨论
相关主题
How to debug "broken pipe" in linux programming ?比较两个文件,把相同的行删除
grep 的很奇怪的现象请教:如何用sed来改变文件中的数字
请教cp后文档属性被自动改变的问题问个关于user/group的粗浅问题
please help: using 'cat' to merge large text files in linux比较二进制文件
[Solved] Ubuntu 8.10安装在外置USB硬盘的问题怎样保证隐私?
弱问:如何copy目录下的所有文件到另外一个目录下?100伪币答谢Linux/Unix编程问题
How to find and delete all hard links to a file (ZZ)linux如何生成可执行文件?
gvim diff question如何把linux命令(多条)打包成可执行文件?(新手)
相关话题的讨论汇总
话题: exe话题: file话题: fd话题: file1话题: data