Quick Perl question...

gopunk

Lifer
Jul 7, 2001
29,239
2
0
is it possible, in a perl script, to pretend that a string is a file? you know how you can pipe output from a program and assign it a filehandle? is there a way to do the same thing, but instead of the output coming from an outside program, it comes from within the script itself?

reason i'm asking is, there's a script i need to use from my script, but it only takes input from files... and i don't think it would be that cool to have to create a new file every time my script is run.
 

dmcowen674

No Lifer
Oct 13, 1999
54,894
46
91
www.alienbabeltech.com
Best bet would be to E-mail Randal Schwartz. He is a world known Perl expert, in fact Intel and the State of Oregon charged him and successfully convicted him for 3 Felony's with $267,000 in fines and restitution for creating a Perl script that he could read his work E-mail from home
. He was an Intel employee :|. This was just before the Internet in 1993.

Join me and many others in trying to get this horrible wrong undone is some way, whether it be a pardon, aquittal, whatever.

David McOwen
http://www.freemcowen.com
 

Rallispec

Lifer
Jul 26, 2001
12,373
3
81
Originally posted by: dmcowen674
Best bet would be to E-mail Randal Schwartz. He is a world known Perl expert, in fact Intel and the State of Oregon charged him and successfully convicted him for 3 Felony's with $267,000 in fines and restitution for creating a Perl script that he could read his work E-mail from home
. He was an Intel employee :|. This was just before the Internet in 1993.

Join me and many others in trying to get this horrible wrong undone is some way, whether it be a pardon, aquittal, whatever.

David McOwen
<a href="http://www.freemcowen.com">http://www.freemcowen.com</A>
wow... thats outrageous, the gov't sucks sometimes
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: dmcowen674
Best bet would be to E-mail Randal Schwartz. He is a world known Perl expert, in fact Intel and the State of Oregon charged him and successfully convicted him for 3 Felony's with $267,000 in fines and restitution for creating a Perl script that he could read his work E-mail from home
. He was an Intel employee :|. This was just before the Internet in 1993.

Join me and many others in trying to get this horrible wrong undone is some way, whether it be a pardon, aquittal, whatever.

David McOwen
<a href="http://www.freemcowen.com">http://www.freemcowen.com</A>
i can't find anything on the websites pertaining to randal schwartz as to what he actually did that led to his prosecution, do you know where i can find that?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
post code :)

you jsut want to use a string instead of a file for input to the script? shouldn't be tough, but I'd like to see how the script is now.
 
Jun 18, 2000
11,005
546
126
Originally posted by: gopunk
i can't find anything on the websites pertaining to randal schwartz as to what he actually did that led to his prosecution, do you know where i can find that?
Ditto. David, what charges did Intel bring up on Schwartz?
 

Ameesh

Lifer
Apr 3, 2001
23,686
0
0
Originally posted by: dmcowen674
Best bet would be to E-mail Randal Schwartz. He is a world known Perl expert, in fact Intel and the State of Oregon charged him and successfully convicted him for 3 Felony's with $267,000 in fines and restitution for creating a Perl script that he could read his work E-mail from home
. He was an Intel employee :|. This was just before the Internet in 1993.

Join me and many others in trying to get this horrible wrong undone is some way, whether it be a pardon, aquittal, whatever.

David McOwen
<a href="http://www.freemcowen.com">http://www.freemcowen.com</A>
he probably had rules withini the company that said he could not do something like that.
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: notfred
post code :)

you jsut want to use a string instead of a file for input to the script? shouldn't be tough, but I'd like to see how the script is now.
uh i actually don't have any code pertaining to this... i wanted to see if it was even possible :p

but i can give you details.... here's the lowdown: this is on a mailing list server. mailing lists can be configured by using a python script to output the settings to a file, editing those settings, then using the same script to input the edited file back. i want to write a cgi script that will run the python script, inputting a "file" with configurations.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
so, right now you have a python script that runs like this:

python script somefile.ext

and what it does, is opens "somefile.ext" changes some stuff, writes "somefile.ext" to disk. opens "somefile.ext" a second time, and then...

wait, I think i've got it...

you run "python script filename"

And the script connects to the server, grabs some config info, writes it to "filename", changes the config info, and then sends the new info to the server???


Ok, I give up, I have no freaking clue what you're trying to do. It seems like there's a bunch of pointless intermediate steps. Why not jsut write a cgi script that writes a new file, rather than opening the same file over and over again, etc....
 

Electric Amish

Elite Member
Oct 11, 1999
23,578
1
0
You're going to have to start charging for your time, notfred :D

I'm now addicted to writing Perl & CGI scripts. I have 2 books on order so I can learn more...... :D

amish
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
Originally posted by: notfred
so, right now you have a python script that runs like this:

python script somefile.ext

and what it does, is opens "somefile.ext" changes some stuff, writes "somefile.ext" to disk. opens "somefile.ext" a second time, and then...

wait, I think i've got it...

you run "python script filename"

And the script connects to the server, grabs some config info, writes it to "filename", changes the config info, and then sends the new info to the server???


Ok, I give up, I have no freaking clue what you're trying to do. It seems like there's a bunch of pointless intermediate steps. Why not jsut write a cgi script that writes a new file, rather than opening the same file over and over again, etc....
aw nuts :p

ok here is what it does.

./config_list -o filename

this will make a file called filename, which contains the settings.

you can then edit this file, and then run:

./config_list -i filename

to actually change the settings.

i want to write a cgi script that calls config_list, so that people can use a webpage to do this. however, i would prefer not having to have an actual file as the "filename"... i would like to assign a filehandle to a string, and pass that filehandle to the python script. sort of like how you can assign a filehandle to the output of a command...

now that i think about it, maybe this wouldn't work because of that whole "passing filehandle" thing...
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
./config_list -i filename

"filename" is not a filehandle. It's just a text string. the python interpreter will open a filehandle connected to the file with the same name as "filename".

You'll have to modify the python script to take input from the command line, or write a new CGI script from scratch. (or write a file as an intermediate step).
 

ASK THE COMMUNITY