LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash scripting - help? (https://www.linuxquestions.org/questions/linux-general-1/bash-scripting-help-751023/)

mickle026 08-29-2009 01:49 AM

bash scripting - help?
 
Can anyone tell me how i can 'export' a directory to use another via programs - I will be extremely grateful.

I will explain.

I am testing some software on a ppc device that has software already on it which i don't want to remove. Its kernel runs, then proprietry interface (similar to nano-x runs), I want to kill the nano-x and run my software.

I have my software in another folder and want to use my share folder instead of the one in the one in the rom. I can run my app, by killing rcS and the interface, then run mine, but its looking for files in /share and i dont want it to. Its not a matter of recoding my app because it uses lots of shared libraries that also look in /share.

I have all other files working fine but instead of the machine reading /share (which is read only) I want to tell the machine that /share is located /mmc_card/share. I cannot backup the folder and symlinking it because its read only (the only user is root so its not a matter of running chown - the hardware is read only)

I can find lots of information of exporting environment variables such as:
EXPORT myfile=`/home/user/app.so'

but i want to
EXPORT /share=`/mmc_media/share'

so that all systems see /mmc_media/share as if its actually /share.

Can I do this in bash??

thanks

pixellany 08-29-2009 02:02 AM

Did you try it?
I think you will find that the statement "export /share=....." simply creates and exports a variable named "/share", and not an entry in the filesystem tree.

I missed why you cannot make a link---root can create symlinks regardless of how permissions are set (I'm pretty sure......)

mickle026 08-29-2009 02:13 AM

Quote:

Originally Posted by pixellany (Post 3661656)
Did you try it?
I think you will find that the statement "export /share=....." simply creates and exports a variable named "/share", and not an entry in the filesystem tree.

I missed why you cannot make a link---root can create symlinks regardless of how permissions are set (I'm pretty sure......)

Yeah I agree with that, but the filesystem is in a rom (read only memory) , it cannot be changed with chown or chmod without changing on the pc, creating new firmware and flashing the device. So no i cannot be linked directly.

export /share=`.....`

gives error:209 .. I cant remember exactly (as im not connected to the device at the moment) but it says the syntax is wrong. I think i cannot use '/' there on the left of the brackets.

Its the filesystem tree i want to "dummy" as /mmc_media/share..

thanks for the reply though

Disillusionist 08-29-2009 03:09 AM

What about using chroot?

I realise that this is a lot more work than what you were probably looking for, but it should allow you to do what you need.

catkin 08-29-2009 04:26 AM

A bash variable name must conform to the OpenGroup's definition of "name" which is a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit. This does not include "/".

catkin 08-29-2009 04:29 AM

Quote:

Originally Posted by mickle026 (Post 3661646)
... but its looking for files in /share and i dont want it to. Its not a matter of recoding my app because it uses lots of shared libraries that also look in /share.

"As ye sow, so shall ye reap". Sorry.

mickle026 08-29-2009 08:16 AM

Quote:

Originally Posted by Disillusionist (Post 3661697)
What about using chroot?

I realise that this is a lot more work than what you were probably looking for, but it should allow you to do what you need.

Im going to look into that later today, thanks for the suggestion. I have never used it, therefore dont know anything (at present) about it.

Changing the root path is probably my only solution, and its not a problem to link back to things that were in the orignal root path.

Thanks again for the suggestion.

mickle026 08-29-2009 02:30 PM

chroot is not is the toolbox (busybox) of the flash, so its also not an option unless I can find it cross compiled individually.

I found a script for rom devices involving setting up a loop device and faking the memory partition elsewhere, im going to take a look at that.

thanks

PTrenholme 08-29-2009 05:12 PM

Perhaps you might consider flashing a more capable version of busybox. (Unless space considerations preclude it.)

The version of busybox on my Fedora 11 system (busybox.anacondia) implements both ln and chroot, which leads me to suspect that your busybox capabilities depend on the options you select when you compile it.

Note that the above is speculation on my part, not actual knowledge.


All times are GMT -5. The time now is 07:04 AM.