- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Why my newcd got problem?
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
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
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
тАО06-23-2002 07:24 PM
тАО06-23-2002 07:24 PM
Here is my .kshrc
set -o vi
set -o monitor
alias ll='ls -la'
alias setprmt='PS1=$HOST"["$USER"]:"${PWD##*/}" "'
setprmt
alias cd=newcd
function newcd
{
\cd "$@" >&- || return 1
setprmt
}
Can anybody tell me if the script for newcd is correct or not, why need \cd "$@" >&- and how to interpret it? Does it support null parameter?
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-23-2002 11:21 PM
тАО06-23-2002 11:21 PM
Re: Why my newcd got problem?
$@=$1$2$3...
($*=$1,$2,$3... where ,=IFS)
<&- = close standard output
In other words, \cd is just the cd with all arguments concatenated. If it failes (||=OR) it returns 1, else it will continue with setting a nice-looking promt (setprmt=PS1-setting).
if you do a 'cd a /b'
i suppose it will do a
cd a/b
, 'cause it should delete the spaces.
If it was upto me, i would not set this newcd.
Regards,
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:04 AM
тАО06-24-2002 12:04 AM
Re: Why my newcd got problem?
myhost[myuser]:opc_op cd
newcd[2]: @: parameter not set
Normal cd will move to my home directory as what 'cd ~' does. How come my newcd cannot?
Other doubts:
1. why there is \ before cd? If I remove it, I will get this,
myhost[myuser]:opc_op cd /usr
ksh: newcd: recursion too deep
2. what is close standard output for &-? Is it the same as normal standard output 1> ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:11 AM
тАО06-24-2002 12:11 AM
Re: Why my newcd got problem?
.kshrc is the same as mentioned above.
Here is .profile,
# Set up the shell variables:
EDITOR=vi
export EDITOR
ENV='${START[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
START=$HOME/.kshrc
export ENV START
LANG=C ; export LANG
PWD=$HOME ; export PWD
SHELL=/bin/ksh ; export SHELL
HOST=`uname -n` ; export HOST
USER=`logname` ; export USER
echo $$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:18 AM
тАО06-24-2002 12:18 AM
Re: Why my newcd got problem?
your .kshrc is run after the .profile because you have the entry:
ENV=.........
This variable tells your system, to source the .kshrc- file for each new kornshell which is started.
and your newcd should work better, if you first run a test- command, to check if there are any parameters given to the function:
if test $# -ne 0
then
your_function_command
else
cd
fi
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:37 AM
тАО06-24-2002 12:37 AM
Re: Why my newcd got problem?
myhost[myuser]:opc_op cd /usr
myhost[myuser]:usr cd
ksh: newcd: recursion too deep
I suspect this could be due to the endless loop of recursion, because cd calls newcd first and then call cd again, and call newcd again and again...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 12:46 AM
тАО06-24-2002 12:46 AM
Re: Why my newcd got problem?
what happens if you delete the ">&-"?
And try to do the same script without "|| return 1".
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2002 04:29 PM
тАО06-24-2002 04:29 PM
Re: Why my newcd got problem?
set -o vi
set -o monitor
alias ll='ls -la'
alias setprmt='PS1=$HOST"["$USER"]:"${PWD##*/}" "'
setprmt
alias cd=newcd
function newcd
{
if test $# -ne 0
then
\cd "$@" >&- || return 1
setprmt
else
\cd
setprmt
fi
}
echo "End of kshrc:"
You see, now I understand why I must put \ before every cd and why we need to create such a newcd in ksh environment.
Thank you very much for your help. I will assign points to you.