The UNIX and Linux Forums  

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
weird file list problem jmmora AIX 8 08-08-2008 12:18 PM
Weird date difference problem meeraKh Shell Programming and Scripting 22 03-12-2008 11:50 PM
Weird crontab problem RobSand SUN Solaris 8 10-09-2007 06:12 PM
weird problem with removing files rein UNIX for Advanced & Expert Users 2 08-15-2005 08:51 AM
Weird Problem??? danhodges99 UNIX for Dummies Questions & Answers 2 04-11-2003 12:05 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-02-2008
vamsi.coe vamsi.coe is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
Angry Weird Variable Evaluation problem

Hi Guys..

I have a script which is:

#!/bin/ksh
for file in `grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2`
do
ls $file
cp $file ./
done


output of grep is
$ grep qtc $PIC_SHS/xback00.ksh |cut -d"=" -f2
$PIC_BIN/XPBACKRC0.qtc
$PIC_BIN/XPBACK000.qtc
$PIC_BIN/XPBACKSS0.qtc
$PIC_BIN/XPBACKSP0.qtc
$PIC_BIN/XPBACKAL0.qtc
$PIC_BIN/XPBACKBO0.qtc
$PIC_BIN/XPBACKTC0.qtc
$PIC_BIN/XPBACKFC0.qtc

$PIC_BIN is a environment variable.

$ ls -l $PIC_BIN/XPBACKRC0.qtc
-rwxrwxrwx 1 ddshupmg gmwms 8448 Feb 7 2007 /disk1/uketddshup/common/bin/XPBACKRC0.qtc

the files exist.. but when give the grep output as input list to for loop, it doesnt evaluate it.. and gives an error like :
$ ./copy.ksh
$PIC_BIN/XPBACKRC0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKRC0.qtc
$PIC_BIN/XPBACK000.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACK000.qtc
$PIC_BIN/XPBACKSS0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKSS0.qtc
$PIC_BIN/XPBACKSP0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKSP0.qtc
$PIC_BIN/XPBACKAL0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKAL0.qtc
$PIC_BIN/XPBACKBO0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKBO0.qtc
$PIC_BIN/XPBACKTC0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKTC0.qtc
$PIC_BIN/XPBACKFC0.qtc: No such file or directory
cp: cannot access $PIC_BIN/XPBACKFC0.qtc


Any idea how to evaluate the variable in for loop.. at shell level it works..
 

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 06:38 AM.


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