WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how find a directory and create symlink automatically  (Read 3313 times)

Offline leoko

  • Newbie
  • *
  • Posts: 10
how find a directory and create symlink automatically
« on: November 14, 2009, 07:42:25 AM »
I explain to them, From TC liveCD I need that a program has access to a folder that CD is inside the liveCD.


the solution for that is to create a symlink to the folder inside liveCD


The problem is that it depends on in that PC places the liveCD as him is called the folder that contains the CD, in some PC, inside mnt the liveCd calls hdc, in others sd0, etc.


then I want to create a script who looks for the folder that is called ROMS inside mnt and that automatically a symlink does and locates it in ~/


for that I manage to find the folder ROMS inside mnt with this command:

find/mnt -name roms

but not as directing this information to the command lm to create a symlink



how might it to do it???

==============================================================

Les explico, Desde TC liveCD necesito que un programa tenga acceso a una carpeta que esta dentro del live CD.


la solucion para eso es crear un symlink a la carpeta dentro liveCD


El problema es que depende de en que PC coloque el liveCD el como se llama la carpeta que contiene el CD, en algunos PC, dentro de mnt el liveCd se llama hdc, en otros sd0, etc.


entonces quiero crear un script que busque la carpeta que se llama ROMS dentro de mnt y que automaticamente haga un symlink y lo ubique en ~/


para eso logro encontrar la carpeta ROMS dentro de mnt con este comando:

find /mnt -name roms

pero no se como dirigir esa informacion al comando lm para crear un symlink



como podria hacerlo ???
Desde el fin del mundo !! .... mmm weno, casi xD

Offline leoko

  • Newbie
  • *
  • Posts: 10
Re: how find a directory and create symlink automatically
« Reply #1 on: November 14, 2009, 08:27:04 PM »
ok, here is the answer

#!/bin/sh
for name in $(find $from_dir /mnt -name roms); do
ln -s $name $to_dir
done


is a bash script, and his find the roms directory inside mnt... later create a symlink to roms in the directory where the symlink is.


simplemente al hacer click es este script se crea un symlink hacia la carpeta roms (el symlink se crea en la carpeta en donde este el script), la gracia que tiene es que busca la carpeta dentro de mnt, eso permite que la carpeta roms este en cualquier unidad de CD del pc con cualquier nombre tal como hdc, sd0, etc,......... la idea de buscar en mnt es que la carpeta roms esta dentro de el live CD
Desde el fin del mundo !! .... mmm weno, casi xD

Offline ^thehatsrule^

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
Re: how find a directory and create symlink automatically
« Reply #2 on: November 17, 2009, 07:41:35 PM »
Note: please keep any non-english text in the "International Talk" subsection