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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2008
gzs553 gzs553 is offline VIP Member  
Supporter
 

Join Date: Oct 2006
Posts: 42
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
Sponsored Links
  #2 (permalink)  
Old 04-11-2008
cfajohnson's Avatar
Shell programmer, author
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,533
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
  #3 (permalink)  
Old 04-14-2008
gzs553 gzs553 is offline VIP Member  
Supporter
 

Join Date: Oct 2006
Posts: 42
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
~
  #4 (permalink)  
Old 04-14-2008
cfajohnson's Avatar
Shell programmer, author
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,533
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?
Sponsored Links
Closed Thread

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 Off


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 06:43 AM
shortcut for tar cvf - [filename] | gzip > [filename].tar.gz bcamp1973 UNIX for Dummies Questions & Answers 4 12-11-2007 05:45 PM
rm $(filename)* sakthi.abdullah Shell Programming and Scripting 4 12-20-2006 09:16 AM
How to send filename as variable in a shell script gthokala9 Shell Programming and Scripting 6 06-27-2006 02:23 PM
AWK Filename as variable firkus UNIX for Dummies Questions & Answers 4 04-16-2004 11:50 AM



All times are GMT -4. The time now is 09:24 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0