Computing.Net > Forums > Unix > strange behaviour in shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

strange behaviour in shell script

Reply to Message Icon

Name: James
Date: December 8, 2003 at 07:19:03 Pacific
OS: hp-ux 10.20
CPU/Ram: unknown
Comment:

I am completely baffled by this problem..I have a shell script. Near the start I declare a series of variables for example:

TODAY="`date +%y%m%d`"
LOGNAME="v$TODAY"
FILEPATH="/tmp/fls"
LOGA=$FILEPATH/$LOGNAME.log

When I send the standard o/p to LOGA it writes to the file /tmp/fls/v031208.log as required.

Later on I define some more variables (all references variables were defined with the variables above):

FILENAME=`cat $NAMEFILE|grep $FILETYPE`
LOGB=$FILEPATH/$FILENAME.log

but now..

echo FILENAME -> v002
echo FILPATH -> /tmp/fls
echo LOGB -> .log/fls/v002

It appends the .log bit to the start! I have tried all kinds of things but it just refuses to put .log at the end. What on earth is going on?

Anyone, please!!

James.



Sponsored Link
Ads by Google

Response Number 1
Name: James
Date: December 8, 2003 at 08:06:55 Pacific
Reply:

Ok, I've boiled the real problem down to the fact that i'm setting FILENAME using `cat $NAMEFILE|grep $FILETYPE`.

If I just do:
$FILENAME=v002
it works.

I tried using " " around the `cat..` command, but no luck. How do I set the result of `cat..` as if I had just declard FILENAME as a string?


0

Response Number 2
Name: hamiltonj
Date: December 8, 2003 at 09:10:37 Pacific
Reply:

Sorted - I was getting bloody ^m s at the end of my lines in $NAMEFILE.

bye


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: strange behaviour in shell script

loops in shell scripts!!! www.computing.net/answers/unix/loops-in-shell-scripts/5140.html

Using hex-code in shell script www.computing.net/answers/unix/using-hexcode-in-shell-script/4227.html

Array size in shell script? www.computing.net/answers/unix/array-size-in-shell-script/5761.html