<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how copy a symlink ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987206#M47339</link>
    <description>&lt;!--!*#--&gt;a big thanks Mike ;)&lt;BR /&gt;&lt;BR /&gt;your script is too complicated for my knowledge but the -f flag for readlink seems to be enough for what i want to do, very interesting parameter.&lt;BR /&gt;&lt;BR /&gt;thanks again.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Cedrick Gaillard</description>
    <pubDate>Sat, 24 Jun 2006 13:58:21 GMT</pubDate>
    <dc:creator>totoperdu</dc:creator>
    <dc:date>2006-06-24T13:58:21Z</dc:date>
    <item>
      <title>how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987202#M47335</link>
      <description>&lt;!--!*#--&gt;hello,&lt;BR /&gt;&lt;BR /&gt;I want to copy the file /lib/ld-linux.so.2 but it's not easy because it's a symlink.&lt;BR /&gt;&lt;BR /&gt;The real problem is to automatically copy the target of this symlink (it's for chrooting).&lt;BR /&gt;&lt;BR /&gt;ls -l gives me:&lt;BR /&gt;/lib/ld-linux.so.2 -&amp;gt; ld-2.3.4.so&lt;BR /&gt;&lt;BR /&gt;in fact, i want to copy the target (ld-2.3.4.so) with the symlink (ld-linux.so.2).&lt;BR /&gt;how can i do that ?&lt;BR /&gt;&lt;BR /&gt;help needed.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Cheers,&lt;BR /&gt;Cedrick Gaillard&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jun 2006 08:32:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987202#M47335</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-06-23T08:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987203#M47336</link>
      <description>Shalom Cedrik,&lt;BR /&gt;&lt;BR /&gt;You can try cp -R the directoy in which the symlink is in. That should work. If it does not, you may need to re-create the link with the ln -s commmand.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Fri, 23 Jun 2006 08:49:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987203#M47336</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-06-23T08:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987204#M47337</link>
      <description>&lt;!--!*#--&gt;it will be too simplistic, i want a minimal chroot environment and i'd like to search and copy the needed libraries automatically.&lt;BR /&gt;&lt;BR /&gt;An example for useradd who returns the needed librairies who are symlink whith the real target:&lt;BR /&gt;root@toto ~]# ldd -v /usr/sbin/useradd |grep "=&amp;gt;" |awk -F"=&amp;gt;" '{print $2}' |awk '{print $1}' |sort -u |xargs ls -l|grep " -&amp;gt; " |awk '{print $9" "$11}'&lt;BR /&gt;/lib/ld-linux.so.2 ld-2.3.4.so&lt;BR /&gt;/lib/libaudit.so.0 libaudit.so.0.0.0&lt;BR /&gt;/lib/libcrypt.so.1 libcrypt-2.3.4.so&lt;BR /&gt;/lib/tls/libc.so.6 libc-2.3.4.so&lt;BR /&gt;&lt;BR /&gt;i don't know how to use this result for concatenate the basename and the last field for integrates it in a script, i'm definitively not a guru ;)&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Cheers,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Fri, 23 Jun 2006 09:02:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987204#M47337</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-06-23T09:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987205#M47338</link>
      <description>&lt;!--!*#--&gt;The readlink command will let you find the value of a symbolic link.  The -f option will expand to a full path.  But that option also follows through multiple symlinks.  If you see a program using a library through multiple symlinks then you would need to copy every step in the symlink chain into the chroot.  This script handles that by following one symlink at a time and adding a directory name for relative paths.&lt;BR /&gt;&lt;BR /&gt;$ cat libs.sh&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;for program in "$@"&lt;BR /&gt;do&lt;BR /&gt; echo "$program"&lt;BR /&gt; ldd -v "$program" | (&lt;BR /&gt; while read f&lt;BR /&gt; do&lt;BR /&gt;  if [[ "$f" =~ ' =&amp;gt; [^ ]' ]]&lt;BR /&gt;  then&lt;BR /&gt;   f="${f#?* =&amp;gt; }"&lt;BR /&gt;   f="${f% ?*}"&lt;BR /&gt;   echo "$f"&lt;BR /&gt;   while [[ -h "$f" ]]&lt;BR /&gt;   do&lt;BR /&gt;    dir="$(dirname "$f")"&lt;BR /&gt;    f="$(readlink "$f")"&lt;BR /&gt;    if [[ ! "$f" =~ '^/' ]]&lt;BR /&gt;    then&lt;BR /&gt;     f="$dir/$f"&lt;BR /&gt;    fi&lt;BR /&gt;    echo " $f"&lt;BR /&gt;   done&lt;BR /&gt;  fi&lt;BR /&gt; done&lt;BR /&gt; )&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You can do the copy itself with "cp -d" to make a new symbolic link that matches a current one.</description>
      <pubDate>Fri, 23 Jun 2006 12:23:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987205#M47338</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2006-06-23T12:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987206#M47339</link>
      <description>&lt;!--!*#--&gt;a big thanks Mike ;)&lt;BR /&gt;&lt;BR /&gt;your script is too complicated for my knowledge but the -f flag for readlink seems to be enough for what i want to do, very interesting parameter.&lt;BR /&gt;&lt;BR /&gt;thanks again.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Sat, 24 Jun 2006 13:58:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987206#M47339</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-06-24T13:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: how copy a symlink ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987207#M47340</link>
      <description>&lt;!--!*#--&gt;with 'readlink -f' i can do:&lt;BR /&gt;# export bin2chr="/usr/sbin/adduser" homechr="/home/newroot"&lt;BR /&gt;# mkdir -p `dirname ${homechr}${bin2chr}`&lt;BR /&gt;# cp -av $bin2chr ${homechr}${bin2chr}&lt;BR /&gt;# for i in `ldd -v ${bin2chr} |grep "=&amp;gt;" |awk -F"=&amp;gt;" '{print $2}' |\&lt;BR /&gt;# awk '{print $1}' |sort -u`; do dirdest="${homechr}`readlink -f $i`"; \&lt;BR /&gt;# mkdir -p `dirname $dirdest`; cp -av `readlink -f $i` $dirdest; done&lt;BR /&gt;# for i in `ldd -v ${bin2chr} |grep "=&amp;gt;" |awk -F"=&amp;gt;" '{print $2}' |\&lt;BR /&gt;# awk '{print $1}' |sort -u`; do cp -av $i ${homechr}${i}; done&lt;BR /&gt;&lt;BR /&gt;thanks the help you have gived me :)&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Cheers,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Mon, 26 Jun 2006 03:28:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-copy-a-symlink/m-p/4987207#M47340</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-06-26T03:28:52Z</dc:date>
    </item>
  </channel>
</rss>

