RE: shell script problem so simple I'm embarassed to ask

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Craig White
Date:  
To: plug-discuss
Subject: RE: shell script problem so simple I'm embarassed to ask
On Fri, 2005-02-11 at 15:56 -0800, Jeremy C. Reed wrote:
> On Fri, 11 Feb 2005, Craig White wrote:
>
> > sorted is nice - directed to a text file was what I was hoping to get...
> >
> > I know this ain't doing that...
> >
> > {
> >    foreach my $elem (sort {$a cmp $b} keys %ENV) {
> >      print "$elem $ENV{$elem}\n" > "/tmp/perldump.txt";
> >    }

> >
> > I am dealing with subroutines that don't direct to standard out
>
> open (DUMPFILE, ">/path/to/perldump.txt");
> ...
> print DUMPFILE "whatever";
> ...
> close (DUMPFILE);
>
> (I purposely removed /tmp/ from your filename example. That leads to
> unsafe tempfile creation and race conditions in simple examples.)

----
I'm sure that there was something you were telling me here...I didn't
get it but I certainly got what I wanted to work using your fine
explanation of open/print/close

{
     open (DUMPFILE, ">/tmp/perldump.txt");
     foreach my $elem (sort {$a cmp $b} keys %ENV) {
     print DUMPFILE "$elem $ENV{$elem}\n";
   }
     close (DUMPFILE);


I are an engnear now! Thanks for the fish

What time does class start tomorrow? I promise I won't be late!

Thanks...

oh and by the way, just to show that I actually did get it...

# cat /tmp/perldump.txt
DOCUMENT_REALROOT /opt/webmin-1.180
DOCUMENT_ROOT /opt/webmin-1.180
GATEWAY_INTERFACE CGI/1.1
HOME /root
HTTPS ON
HTTP_ACCEPT text/xml,application/xml,application/xhtml
+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_ACCEPT_ENCODING gzip,deflate
HTTP_ACCEPT_LANGUAGE en-us,en;q=0.5
HTTP_CONNECTION keep-alive
HTTP_COOKIE testing=1
HTTP_HOST linuxserver.azapple.com:8000
HTTP_KEEP_ALIVE 300
HTTP_REFERER https://linuxserver.azapple.com:8000/config.cgi?ldap-
useradmin
HTTP_USER_AGENT Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041111 Firefox/1.0
LD_LIBRARY_PATH
MINISERV_CONFIG /etc/webmin/miniserv.conf
PATH /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
PATH_INFO
PATH_REALTRANSLATED /opt/webmin-1.180/
PATH_TRANSLATED /opt/webmin-1.180/
PWD /opt/webmin-1.180/ldap-useradmin
QUERY_STRING
REMOTE_ADDR 192.168.2.10
REMOTE_HOST 192.168.2.10
REMOTE_USER admin
REQUEST_METHOD GET
REQUEST_URI /ldap-useradmin/
SCRIPT_FILENAME /opt/webmin-1.180/ldap-useradmin/index.cgi
SCRIPT_NAME /ldap-useradmin/
SERVER_ADMIN
SERVER_NAME linuxserver.azapple.com
SERVER_PORT 8000
SERVER_PROTOCOL HTTP/1.0
SERVER_REALROOT /opt/webmin-1.180
SERVER_ROOT /opt/webmin-1.180
SERVER_SOFTWARE MiniServ/0.01
WEBMIN_CONFIG /etc/webmin
WEBMIN_VAR /var/webmin

nice alphabetic touch from Ben (thanks Ben) - I'm now a perl guru

NOT

Craig

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss