Re: STDout

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Fri, Jan 17, 2003 at 03:12:05PM +1100, Patrick.Barnes at transgrid.com.au
wrote:
> 
> Hmm... I think that would be too slow.
> 
> I have to ping 1300 names, and for each record what the IP address resolves
> too, and whether the ping a) succeeds b)times out or c) does not resolve the IP
> address
> 
> Any alternative to piping the ping output into a file, and reading it 1300
> times?
> 

Use >> instead of >, and read it in once, instead of 1300 times.

However, using real pipes would be better. (I know how to do this for Linux,
but not windows, sry.)

jbrown

> 
> -----Original Message-----
> From: jbrown1050 at hotpop.com [mailto:jbrown1050 at hotpop.com]
> Sent: Friday, 17 January 2003 13:53
> To: EUforum
> Subject: Re: STDout
> 
> 
> On Fri, Jan 17, 2003 at 12:51:36PM +1100, Patrick.Barnes at transgrid.com.au
> wrote:
> > 
> > In a command-line interface (DOS, not linux) adding "> filename"
> > to the end of your command redirects the output to a file instead.
> > 
> > Is there any other places you can redirect it? Ideally, I'd like
> > a system() command that returns a string to the euphoria program.
> 
> The redirection thing applies to Linux as well btw, jtlyk.
> 
> There is like popen() for linux to do that sort of redirection you want,
> for DOS it can be emulated.
> 
> I've included at the very bottom of this message some sample code, which works
> on ANY platform, that acts like system(), but returns the output.
> 
> It merely redirects the output to a temp file, then reads the output from
> the file into a string, and then deletes the temp file, however.
> 
> (To the best of my knowledge thats the only way to do it for DOS. Even the
> shell
> uses temporary files to simulate command line pipes iirc.)
> 
> jbrown
> 
> > 
> > =======================
> > Patrick Barnes
> > Information Systems Group
> > 201 Elizabeth St, Sydney
> > Patrick.Barnes at transgrid.com.au
> > Ext: 91-3583
> > Ph:(02) 9284-3583
> > Mob: 0410 751 044
> > 
> > 
> > ***********************************************************************
> > 
> > 
> > ***********************************************************************
> > 
> > 
> > TOPICA - Start your own email discussion group. FREE!
> 
> ---the file
> --start comout.e
> -- command output
> -- emulates bash's `command` abilites.
> -- very convient
> -- slightly modified for use in DOS
> constant tempfile = "c:\\temp\\euout.tmp"
> --include fset.e --simplified file operations
> --start fset.e
> function readf(sequence name)
> 	sequence data
> 	integer h
> 	h = open(name, "r")
> 	if h = -1 then
> 		return ""
> 	end if
> 	data = ""
> 	while 1 do
> 		data &= getc(h)
> 		if data[length(data)] = -1 then
> 			data = data[1..length(data)-1]
> 			exit
> 		end if
> 	end while
> 	close(h)
> 	return data
> end function
> procedure writef(sequence name, sequence data)
> 	integer h
> 	h = open(name, "w")
> 	if h = -1 then
> 		return
> 	end if
> 	puts(h, data)
> 	close(h)
> end procedure
> function breadf(sequence name)
> 	sequence data
> 	integer h
> 	h = open(name, "rb")
> 	if h = -1 then
> 		return ""
> 	end if
> 	data = ""
> 	while 1 do
> 		data &= getc(h)
> 		if data[length(data)] = -1 then
> 			data = data[1..length(data)-1]
<snip>

> 
> 
-- 
 /"\  ASCII ribbon
 \ /  campain against
  X   HTML e-mail and
 /*\  news and unneeded MIME

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu