- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: SHELL used sh: tr command not working in home ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 12:12 AM
тАО07-31-2008 12:12 AM
SHELL used sh: tr command not working in home directory and works fine in other directories
Ex. Following command is not woring from home directory
echo TEST | tr [:upper:] [:lower:]
tr: The combination of options and String parameters is not legal.
Usage: tr [ -c | -cds | -cs | -ds | -s ] [-A] String1 String2
tr [ -cd | -cs | -d | -s ] [-A] String1
but in $HOME/abc its working fine without making any change.
Can you please advice and suggect some workaround?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 12:20 AM
тАО07-31-2008 12:20 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
i see no issues, whats your system os version and patch level.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 12:21 AM
тАО07-31-2008 12:21 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
Do you have "." in your PATH and a tr in your home directory?
Try "whence tr" in both places.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 12:23 AM
тАО07-31-2008 12:23 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
stty -a
env | more
Check the environment and settings. There is clearly an error in the user environment.
PATH most likely.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 12:24 AM
тАО07-31-2008 12:24 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
If there is nothing in $HOME/abc, the shell finds nothing matching the "wildcards" and passes the arguments as-is.
Try adding single quotes around the tr strings:
echo TEST | tr '[:upper:]' '[:lower:]'
That prevents the shell wildcard expansion from touching the arguments of tr.
Another alternative would be that you have the directory "." listed in your PATH and you have a non-default "tr" command in your home directory.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 02:44 AM
тАО07-31-2008 02:44 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
1) If it is an environment issue it should give problem in child directory. As I am not changing the environment.
2) There is no tr file in my home directory.
3) We can not put quotes since it requires changes in number of scripts.
Please let me know if it is a known issue and applying some patch would solve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 03:27 AM
тАО07-31-2008 03:27 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
But the HP posix shell offers a feature that even Bash lacks to my knowledge (probably zsh has it?)
There are these case specific options with the typeset command in sh-posix
that entirely make any tr or sed fumbling redundant.
A shell var declared to only hold lower case will always output lower case even if the assigment was upper case.
e.g.
$ typeset -l lcvar
$ lcvar=TEST
$ echo $lcvar
test
Maybe an alternative for your next script overhaul?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 05:53 AM
тАО07-31-2008 05:53 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
> arguments to tr as wildcards, [...]
Sounds likely to me. Note that in "man tr",
these character classes are always quoted.
For example:
[...]
In a case conversion, however, the string2 array
contains only those characters defined as the
second characters in each of the toupper or
tolower character pairs, as appropriate. For
example:
tr -s '[:upper:]' '[:lower:]'
[...]
Perhaps they were quoted for a reason.
> 3) We can not put quotes since it requires
> changes in number of scripts.
Then I guess that you're out of luck. In
other words, "Making my badly written scripts
work correctly is too much work."?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 06:43 AM
тАО07-31-2008 06:43 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
other words, "Making my badly written scripts
work correctly is too much work."?
---- I dont think the scripts are badly written. The ascripts are in use since many years and working in our environment as well. I think this is something related to the environment on the HP server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 08:50 AM
тАО07-31-2008 08:50 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
followed by
"I think this is something related to the environment on the HP server."
You were more than likely correct the first time. You said it doesn't work in the home dir but does in the child. Is this from a script or the command line?
"The ascripts are in use since many years and working in our environment as well."
Ok, so what's changed recently?
What is your PATH variable set to?
What is the contents of your HOME directory?
What does "whence tr" report?
Does "echo TEST | tr [E] [e]" work and give "TeST"?
BTW: I can reproduce the behavior you are seeing, but only in the C-shell. What's the script using????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 09:20 AM
тАО07-31-2008 09:20 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
to re-use your words: of course the script is badly written - you did not care for quoting and did not take filename expansion into account.
sh
$ mkdir new
$ cd new
$ ls [:upper:]
[:upper:]: No such file or directory
$ touch u
$ ls [:upper:]
u
On my SUN the message differs but has the same cause:
echo TEST | tr [:upper:] [:lower:]
tr: String2 contains an invalid character class.
The correct way would be to use
$ echo TEST | tr '[:upper:]'
'[:lower:]'
test
As a hack, you can disable filename expansion, if you do not need it elsewhere:
$ set -f
$ echo TEST | tr [:upper:] [:lower:]
test
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 09:32 AM
тАО07-31-2008 09:32 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
Peter N. nailed it. Follow his test (no pun intended) and you will see the behavior is the same on HP-UX.
As Steven S. said, there is good reason the manpages show examples with quotes.
I'm sorry to say that your scripts are simply badly written. They don't work 100% of the time, and that's just not good.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 08:14 PM
тАО07-31-2008 08:14 PM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
Rats, I was trying to test that so I created a file "[:upper:]". But that worked.
Only when I read Steven's did I get it:
tr [epru:] [elorw:]
Which is: echo tr [epru:] [elorw:]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2008 06:13 AM
тАО08-04-2008 06:13 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
find /home/ -name \? -print
Quoting the command as advised above is best.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2008 01:24 AM
тАО09-08-2008 01:24 AM
Re: SHELL used sh: tr command not working in home directory and works fine in other directories
This fault is often caused by a single character filename in the directory.
find /home/ -name \? -print
Quoting the command as advised above is best.