LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Can Linux serve "virtual" files which are (re)produced by script when accessed? (https://www.linuxquestions.org/questions/linux-server-73/can-linux-serve-virtual-files-which-are-re-produced-by-script-when-accessed-789774/)

batonac 02-17-2010 01:23 PM

Can Linux serve "virtual" files which are (re)produced by script when accessed?
 
Is it possible to run a Linux file server which lists files which don't actually exist, but rather are generated on the fly by a (bash) script that runs and returns file data every time the given file is requested??

For example, I have a huge store of XCF images. I want to keep the XCF images, but for many purposes I must access these images as PNG files. I don't want to keep multiple copies of each image, and I don't want to have to save an image twice each time I edit it. What I would like is a FTP or SMB file server which lists each image twice, but serves the original every time the XCF is accessed, and uses imagemagick to convert the XCF into PNG on the fly, and serves that data every time the PNG is accessed.

I know that there is a time trade off here, but this scenario totally fits my use-case, and I would deeply appreciate if anyone could direct me in accomplishing this.

This is an new experience for me. I've never heard of anyone trying to do this, and I can't seem to type the right google searches to find others on the world who have done the same thing. Yet it seems like it should be totally possible through the power of Linux.

I guess this would be like a really fancy and advanced link, but one which links to info that has yet to be produced. (Kinda like /dev/random ?)

fang0654 02-17-2010 01:50 PM

Your best bet is using a web application, that lists out the files, and does the conversion when you click, and serves up converted file.

It should be pretty simple to do in php/perl. I don't know of any projects off the top of my head that do this already, though.

batonac 02-17-2010 04:05 PM

Quote:

Originally Posted by fang0654 (Post 3867243)
Your best bet is using a web application, that lists out the files, and does the conversion when you click, and serves up converted file.

It should be pretty simple to do in php/perl. I don't know of any projects off the top of my head that do this already, though.

Thanks for a quick response!

I wish I didn't have to learn a new language, and this probably won't work with my specific program needs, but maybe I can just run a cron script that creates actual copies of the images and updates them daily, although this would not be ideal in my mind. Any other ideas would be great...

fang0654 02-17-2010 04:10 PM

Check this out:

http://sourceforge.net/projects/simpledirectory/

You would have to add a function in there for file conversion, but it shouldn't be very difficult.

batonac 03-04-2010 07:41 AM

Quote:

Originally Posted by fang0654 (Post 3867386)
Check this out:

http://sourceforge.net/projects/simpledirectory/

You would have to add a function in there for file conversion, but it shouldn't be very difficult.

Thanks for the suggestion, I think that instead of this, I will probably just make a cron script which (re)produces png files for all of the xcf files in my directory, on a given time basis (every night).

If anyone knows how to do otherwise, I would be glad to know.

Thanks again, the Linux community rocks!!

zhjim 03-04-2010 08:02 AM

Maybe check out fuse. It just seams right for your purpose. Also you would have to get your hands dirty with programming.

Here are to links one for fuse

http://en.wikipedia.org/wiki/FUSE_(linux)

and one that shows how to create your own filesystem for use with fuse

http://www.ibm.com/developerworks/linux/library/l-fuse/


All times are GMT -5. The time now is 02:32 AM.