The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ls -d does not work nir_s Shell Programming and Scripting 11 01-12-2009 12:47 PM
FTP doesn't work Torquemada UNIX for Dummies Questions & Answers 2 07-13-2008 04:31 PM
How does it work? nat123 Linux 1 11-05-2007 01:13 AM
cant get this to work iago UNIX for Dummies Questions & Answers 6 09-06-2007 04:41 PM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 10:52 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-25-2009
vishwesh vishwesh is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
Lipo doesn't work

Hi guys,
Am using lipo to merge ppc and i386 version of a static/dylib file based on "file type to load". I am working on Mac OS 10.5.6 and new to shell scripting. Please help me out.

This is my code.
Code:
echo "This file combine ppc and i386 file to form universal library"

echo "source Path: "
read path
echo "source Path1: "
read path1
echo "destination : "
read dest

echo "file type to load"
read exten

for iFile in `find $path -type f -name $exten`
do
    echo $iFile
    iFile1="${path1}${iFile##*/}"
    echo $iFile1
    destFile="${dest}${iFile##*/}"
   lipo -create $iFile $iFile1 -output destFile
done

echo "***   Done   ***"
It's say lipo can't load the file in iFile. I am trying to run lipo command.
  #2 (permalink)  
Old 08-25-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361

Does the file in $iFile exist?

Your script will fail if any of the filenames contain spaces.

Is $exten a complete file name or an extension? Could it contain wildcards?

Code:
find $path -type f -name "*$exten" |
 while read iFile
 do
    echo $iFile
    iFile1=${path1%/}/${iFile##*/}
    echo $iFile1
    destFile="${dest%/}/${iFile##*/}"
   lipo -create "$iFile" "$iFile1" -output destFile
 done
  #3 (permalink)  
Old 08-26-2009
vishwesh vishwesh is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
Code:
find $path -type f -name "*$exten" |
 while read iFile
 do
    echo $iFile
    iFile1=${path1%/}/${iFile##*/}
    echo $iFile1
    destFile="${dest%/}/${iFile##*/}"
   lipo -create "$iFile" "$iFile1" -output "$destFile" # changed the last line
 done
I figured out the problem in my script ,
It generated this path
"/sw/lib/ImageMagick-6.5.4/modules-Q16/codersycbcr.a"
which should have been
"/sw/lib/ImageMagick-6.5.4/modules-Q16/coders/ycbcr.a"

Thank you very much. I normally feed exten wildcards "*.a" or "*.dylib". I need to make checks for file existence.

Quote:
Your script will fail if any of the filenames contain spaces.
I have faced that problem too. How should I handle white spaces in file paths?
  #4 (permalink)  
Old 08-26-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by vishwesh View Post
Quote:
Your script will fail if any of the filenames contain spaces.
I have faced that problem too. How should I handle white spaces in file paths?

Always quote variables.

Never use:
Code:
for file in $( some_command )
Always pipe the output of the command into a loop instead:
Code:
some_command |
 while read file
 do
   : do whatever with "$file" (not $file)
 done
  #5 (permalink)  
Old 08-26-2009
vishwesh vishwesh is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 4
Thanks a lot.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0