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.
command TR suddenly fails
Name: tvc02 Date: June 3, 2008 at 07:02:58 Pacific OS: w2k CPU/Ram: n/a Product: n/a
Comment:
Using TR command like this:
echo Test | tr [A-Z] [a-z]
... with Bourne shell. Worked OK for a bunch of users on same server, suddenly, it does not work anymore for 1 particular user.
I do not see any differences between this user and other ones. When it fails, he just displays : "Test"
Name: med (by medigeek) Date: June 3, 2008 at 07:57:37 Pacific
Reply:
try: echo Test | tr [:upper:] [:lower:]
maybe it's a different shell? what does "echo $0" say?
0
Response Number 2
Name: tvc02 Date: June 4, 2008 at 03:47:06 Pacific
Reply:
The shell is not different, both have /usr/bin/bash as shell, checked that as first thing.
If I use syntax:
echo Test | tr [:upper:] [:lower:]
... I'm getting "Bad String", on the user that does work, if you do :
echo Test | tr [upper] [lower]
I'm gessing that the TR command is just buggy, but I would like somebody to confirm this. There's obviously an external factor, deciding on the behaviour of this command, which should not be.
0
Response Number 3
Name: nails Date: June 4, 2008 at 10:32:58 Pacific
Reply:
Does it help to place quotes around the tr arguments:
echo Test | tr "[A-Z]" "[a-z]"
0
Response Number 4
Name: tvc02 Date: June 9, 2008 at 01:56:40 Pacific
Reply:
That works perfectly, Thanks
Can you explain why it sometimes works without the quotes ?
0
Response Number 5
Name: nails Date: June 9, 2008 at 20:07:29 Pacific
Reply:
I'm running these tr tests on a Solaris 9 unix box. Both examples work fine, but the Solaris tr MAN pages examples exclusively use quotes around the tr arguments.
Until I saw your post, I had never heard of not using quotes. I looked in my favorite Unix reference - Unix in a Nutshell - and this reference exclusively uses quotes.
If I were you, I'd exclusively use quotes as obviously without quotes tr usage is inconsistent.
0
Response Number 6
Name: tvc02 Date: June 10, 2008 at 02:06:32 Pacific
Reply:
OK Thanks, I'm using Solaris 10 by the way
I need to updat all my scripts now, because otherwise it does not run for this one unix-user only, since some days, for an unknown reason
0
Response Number 7
Name: isavant01 Date: December 5, 2008 at 08:46:57 Pacific
Reply:
globbing.
you'll probably find that there is/was a file in the current directory that MATCHED the [a-z] or [A-Z] on your tr command line.
the shell interpreted the UNquoted [a-z] or [A-Z] AS the file so named ... which completely blew up what you were trying to do.
"That's the problem with these things [computers], they do what you tell them, not what you meant to tell them." --- Danielle Needle
Summary: Hi: This is a common problem with any shell script that runs fine from the command line, but fails from cron. You need to set up your environment in the script - primarily PATH and any environmental v...
Summary: Typically, when a program works from the command line, but fails from cron, it is because the program excecuting isn't finding a required executable. Also, in most unix variants, the default for cron ...
Summary: Your e-mail is not accepting messages at this time. I might can help, but I need the info that I asked for above, which is the exact find command that is failing. ...