1. Linux question
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Aug 13, 2001
- 495 views
What is ther Linux equivalent of the following DOS command? IF EXIST FILE1.TXT DEL FILE1.TXT (Does rm complain if you try to delete a non-existent file?) Thanks. -- Mike Nelson
2. Re: Linux question
- Posted by euphoria at carlw.legend.uk.com Aug 13, 2001
- 464 views
Mike Nelson wrote: > What is the Linux equivalent of the following DOS command? > > IF EXIST FILE1.TXT DEL FILE1.TXT rm -f file1.txt > (Does rm complain if you try to delete a non-existent file?) Not if you use the -f (force) flag. (It's a good job I parsed the DOS command as a whole, because doing an IF EXIST usually depends on the shell you're using. ;) ) Carl
3. Linux question
- Posted by Irv Mullins <irvm at ellijay.com> Apr 21, 2001
- 440 views
I need to create unique temporary files, which I can do using mktemp , i.e. system_exec('mktemp myprog.XXXXXX',0) The question is, how do I find out what name mktemp has used to create my file? The name is normally printed on the console, and I don't kow how to redirect that so Euphoria can get to it. Thanks, Irv
4. Re: Linux question
- Posted by Ted Fines <fines at macalester.edu> Apr 21, 2001
- 453 views
You could do it like this: function getrandfilename() integer r1,r2,r3,limit limit=1000000 -- some big number r1=rand(limit) r2=rand(limit) r3=rand(limit) return sprintf("%s",r1) & "." & sprintf("%s",r2) & "." & sprintf("%s",r3) & ".tmp" -- the filename would be a filename like '65783.999070.12.tmp' -- the odds of creating a duplicate would be 1/limit^3 (very very slim) -- The '.' between each number is totally unnecessary. end function sequence myfile myfile = getrandfilename() I've been doing something like this in a program of mine to create unique filenames, and it has worked perfectly well. I guess there's always a chance of a duplicate, but there's a chance I'll win the Powerball lottery too. Neither chance keeps me up at night. Or, maybe you could do it with just Linux commands: system_exec("declare -x `myprogXXXXXX`",0) NOTE: In the command above, the single tics are back-tics (the one on the same key as the tilde key, next to the 1 key). This command will create an environment variable in RAM with the same name as the temp file it creates. You can't use the '.' character in the name, but hey, you don't really need to, anyway... Then just read the enviroment variable and you've got your name...Some procedure using that might work for you. The declared variable won't persist between shell sessions, though. Using the back-tics are one of the coolest shell features of Unix, I think... :) --Ted --On Saturday, April 21, 2001 08:29:54 AM -0500 Irv Mullins <irvm at ellijay.com> wrote: > > > > I need to create unique temporary files, which I can do using > mktemp , i.e. system_exec('mktemp myprog.XXXXXX',0) > > The question is, how do I find out what name mktemp has used > to create my file? The name is normally printed on the console, > and I don't kow how to redirect that so Euphoria can get to it. > > Thanks, > Irv > > > > >
5. Re: Linux question
- Posted by Wolf <wolfritz at KING.IGS.NET> Apr 21, 2001
- 443 views
> Irv Mullins wrote: >> I need to create unique temporary files, which I can do using >> mktemp , i.e. system_exec('mktemp myprog.XXXXXX',0) >> The question is, how do I find out what name mktemp has used >> to create my file? The name is normally printed on the console, >> and I don't kow how to redirect that so Euphoria can get to it. How about just using EU's date/time functions to create your own unique 'hex' character file name ?