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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Variable value not being fetched in the filename.. RRVARMA Shell Programming and Scripting 3 06-01-2008 02:43 AM
shortcut for tar cvf - [filename] | gzip > [filename].tar.gz bcamp1973 UNIX for Dummies Questions & Answers 4 12-11-2007 01:45 PM
rm $(filename)* sakthi.abdullah Shell Programming and Scripting 4 12-20-2006 05:16 AM
How to send filename as variable in a shell script gthokala9 Shell Programming and Scripting 6 06-27-2006 10:23 AM
AWK Filename as variable firkus UNIX for Dummies Questions & Answers 4 04-16-2004 07:50 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-11-2008
Supporter
 

Join Date: Oct 2006
Posts: 39
mv Filename variable to another filename

Anyone who can assist :

I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

It will not pass to variable.
Anyone have any ideas what I am doing wrong here.
Thanks



# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`
savegrp=/export/legato/scripts/savegrp_rpt.tmp
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat
cat $* > $savegrp
group=`head -1 $savegrp |grep -v -i media |awk '{print $4,$5}'`>/dev/null
#/usr/ucb/mail -s "$group Test Savegroup Report - $rdat" < $savegrp
#cp $savegrp $rtp_savegrp
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-11-2008
cfajohnson's Avatar
Registered User
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 471
Quote:
Originally Posted by gzs553 View Post
Anyone who can assist :

I am trying to pass the group vairiable to a filename:
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

It will not pass to variable.

What do you mean, "will not pass to variable"? What does happen? What do you want to happen?

Are both "$group_savegrp_rpt" and "$dat defined"?

Or do you mean:

Code:
rpt_tsavegrp=/export/legato/scripts/${group}_savegrp_rpt.$dat
Quote:
# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`

Why make two identical calls to an external command?

Code:
rdat=$dat
Quote:
savegrp=/export/legato/scripts/savegrp_rpt.tmp
rpt_tsavegrp=/export/legato/scripts/$group_savegrp_rpt.$dat

Where is $group_savegrp_rpt defined?
Quote:
cat $* > $savegrp

That will fail if there are any spaces in the arguments. Use:

Code:
cat "$@" > "$savegrp"
Quote:
group=`head -1 $savegrp |grep -v -i media |awk '{print $4,$5}'`>/dev/null

What are you sending to /dev/null? If it's outside the backticks, you are doing nothing, since an assignment doesn't produce any output. If it's inside, there will be nothing assign to the variable.

It's not clear what you are trying to do here. Whatever it is, you can almost certainly do it without calling three external commands; in fact, probably without any:

Code:
read a b c d e f < "$savegrp"
case "$a $b $c $d $e $f" in ## adjust to where 'media' might appear
  *media*) group="$d $e" ;;
esac
Quote:
#/usr/ucb/mail -s "$group Test Savegroup Report - $rdat" < $savegrp
#cp $savegrp $rtp_savegrp
Reply With Quote
  #3 (permalink)  
Old 04-14-2008
Supporter
 

Join Date: Oct 2006
Posts: 39
For some reason, my $group vairable will not pass to the $savgrp_rpt.
Still doesn't work.

# This script sends email that save group completed.
#!/bin/ksh
dat=`date +%m%d%y`
rdat=`date +%m/%d/%y`
tmp_savegrp=/export/legato/rpts/savegrp.tmp
cat $@ > $tmp_savegrp
group=`head -1 $tmp_savegrp |grep -v -i media |awk '{print $4,$5,$10}'
/usr/ucb/mail -s "$group Savegroup Report - $rdat" xxxx@xxx.com < $tmp_savegrp
savgrp_rpt=/export/legato/rpts/${group}_savegrp_rpt.$dat
cp $tmp_savegrp $savgrp_rpt
~
Reply With Quote
  #4 (permalink)  
Old 04-14-2008
cfajohnson's Avatar
Registered User
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 471
Quote:
Originally Posted by gzs553 View Post
For some reason, my $group vairable will not pass to the $savgrp_rpt.

Where did you define $group?

If it is in a parent process, did you export it?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0