Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - shell script gurus here?: (5 Items)
   
shell script gurus here?  
Hi,

I have a target embedded filesystem with various QNX files, that on the host are in bin, sbin, usr/sbin, etc. On my 
target they are all in bin. Now I want to replicate this setup for another CPU platform.

I thought of a shell script that takes the output from ls /bin on the target and on the host (mounted via NFS) does a 
find on /usr/qnx641/target/qnx6/[myCPU-arch] and so generates a list of all the files with paths on the host.

Then the script would copy all the files from their host locations to a new directory bin. This new directory I would 
then copy to the new, other target.

This surely can be done with a smart shell script, but I don't know how to do it. It's too long ago that I did some 
scripts... Anyone know how to do this?


- Malte
Re: shell script gurus here?  
On Wed, Aug 19, 2009 at 11:40:37AM -0400, Malte Mundt wrote:
> Hi,
> 
> I have a target embedded filesystem with various QNX files, that on the host are in bin, sbin, usr/sbin, etc. On my 
target they are all in bin. Now I want to replicate this setup for another CPU platform.
> 
> I thought of a shell script that takes the output from ls /bin on the target and on the host (mounted via NFS) does a 
find on /usr/qnx641/target/qnx6/[myCPU-arch] and so generates a list of all the files with paths on the host.
> 
> Then the script would copy all the files from their host locations to a new directory bin. This new directory I would 
then copy to the new, other target.
> 
> This surely can be done with a smart shell script, but I don't know how to do it. It's too long ago that I did some 
scripts... Anyone know how to do this?

Something like:

find /bin -type f | while read line; do /
find /usr/qnx641/target/qnx6/x86 ${line} -exec "cp {} /dst" ; done

-seanb
Re: shell script gurus here?  
> On Wed, Aug 19, 2009 at 11:40:37AM -0400, Malte Mundt wrote:
> > Hi,
> > 
> > I have a target embedded filesystem with various QNX files, that on the host
>  are in bin, sbin, usr/sbin, etc. On my target they are all in bin. Now I want
>  to replicate this setup for another CPU platform.
> > 
> > I thought of a shell script that takes the output from ls /bin on the target
>  and on the host (mounted via NFS) does a find on /usr/qnx641/target/qnx6/[
> myCPU-arch] and so generates a list of all the files with paths on the host.
> > 
> > Then the script would copy all the files from their host locations to a new 
> directory bin. This new directory I would then copy to the new, other target.
> > 
> > This surely can be done with a smart shell script, but I don't know how to 
> do it. It's too long ago that I did some scripts... Anyone know how to do this
> ?
> 
> Something like:
> 
> find /bin -type f | while read line; do /
> find /usr/qnx641/target/qnx6/x86 ${line} -exec "cp {} /dst" ; done

Yeah... but the second find, like this, finds everything in the directory. However, when I change the line to

find /usr/qnx641/target/qnx6/x86 -name ${line} -exec "cp {} /dst" ; done

it doesn't find anything anymore! What could be the problem? (of course files in bin are cat, etc., and should be found.
.)


- Malte

Re: shell script gurus here?  
On Thu, Aug 20, 2009 at 10:44:16AM -0400, Malte Mundt wrote:
> > Something like:
> > 
> > find /bin -type f | while read line; do /
> > find /usr/qnx641/target/qnx6/x86 ${line} -exec "cp {} /dst" ; done
> 
> Yeah... but the second find, like this, finds everything in the directory. However, when I change the line to
> 
> find /usr/qnx641/target/qnx6/x86 -name ${line} -exec "cp {} /dst" ; done

find /usr/qnx641/target/qnx6/x86 -name $(basename ${line}) -exec "cp {} /dst" ; done

-seanb
Re: shell script gurus here?  
> On Thu, Aug 20, 2009 at 10:44:16AM -0400, Malte Mundt wrote:
> > > Something like:
> > > 
> > > find /bin -type f | while read line; do /
> > > find /usr/qnx641/target/qnx6/x86 ${line} -exec "cp {} /dst" ; done
> > 
> > Yeah... but the second find, like this, finds everything in the directory. 
> However, when I change the line to
> > 
> > find /usr/qnx641/target/qnx6/x86 -name ${line} -exec "cp {} /dst" ; done
> 
> find /usr/qnx641/target/qnx6/x86 -name $(basename ${line}) -exec "cp {} /dst" 
> ; done
> 
> -seanb


Ah, basename, of course! This works. Thank you very much!


- Malte