Operating System - HP-UX
1827458 Members
5546 Online
109965 Solutions
New Discussion

Re: Manipulation of variables

 
SOLVED
Go to solution
Jose Mosquera
Honored Contributor

Manipulation of variables

Hi Pals,

I have the MYVAR variable with the following content:
#echo $MYVAR
REPORT`date +%d%m%y`.txt

So, I need use this content with the date resolution (REPORT280403.txt), Some idea about this?

Regards
10 REPLIES 10
John Poff
Honored Contributor

Re: Manipulation of variables

Hi,

If I understand what you are asking, you want the REPORT variable to have the 'date' construct in it? I'm not sure you can do that. I would suggest setting the date in a variable and then substituting that value into the REPORT variable, something like this:

MYDATE=$(date +%d%m%y)
MYVAR=REPORT${MYDATE}.txt

JP
Steven E. Protter
Exalted Contributor

Re: Manipulation of variables

TIMESTAMP=`date +%I%M%S.%Y%m%d`
LOGFILE=/tmp/oas/forms6i_${TIMESTAMP}.log

Real life example.

This is how we track forms server startups.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Zafar A. Mohammed_1
Trusted Contributor

Re: Manipulation of variables

You can do like this
tdate=`date +%d%m%y`
myvar=REPORT${tdate}.txt
echo "Filename : $myvar "

Filename : REPORT280403.txt

Thanks
Zafar

Jose Mosquera
Honored Contributor

Re: Manipulation of variables

Hi again,

None answer is useful for me.
Simply imagine that I have the variable with that content, but I need to use the resultant of the execution of the contained command in it.

I read this content (REPORT`date +%d%m%y`.txt)from a plain file, then I will try to use it in the following final command:
uuenconde source.txt $MYVAR|mailx -s Test user@domain

When I try this way the following message appear: Usage: uuencode [ source ] remotedest

Regards
Tom Maloy
Respected Contributor

Re: Manipulation of variables

Try using eval:

uuenconde source.txt `eval $MYVAR` | mailx -s Test user@domain
Carpe diem!
Zafar A. Mohammed_1
Trusted Contributor

Re: Manipulation of variables

Jose,

Just copy and test it:

uuenconde source.txt ${MYVAR}|mailx -s Test user@domain

Thanks
Zafar
Jose Mosquera
Honored Contributor

Re: Manipulation of variables

Tom,

Regrettably it has not worked!

Regards
Jose Mosquera
Honored Contributor

Re: Manipulation of variables

Zafar,

I have attempted your recommendation before obtaining into the outgoing email body:
Usage: uuencode [ source ] remotedest

Regards
Tom Maloy
Respected Contributor
Solution

Re: Manipulation of variables

Different eval:

eval uuencode source.txt ${MYVAR}|mailx -s Test user@domain
Carpe diem!
Peter Nikitka
Honored Contributor

Re: Manipulation of variables

The command depends on the Shell, you are using:
KSH,Bourne,...:
eval MYVAR=$MYVAR
TCSH,...:
eval set MYVAR=$MYVAR

If you do need the old setting of MYVAR futher on, take another variable.
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"