- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Passing parameters to middle of alias script
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
тАО07-21-2000 04:51 AM
тАО07-21-2000 04:51 AM
Passing parameters to middle of alias script
They want to set up an alias called Z to print a file in the background. I think it should look like
export alias Z='cat $1 &'
or
export alias Z='cat $* &'
All test show
ksh: 1: parameter not set
ksh: /etc/motd: cannot execute
TIA. Also if I did not assign some points to a question yesterday is it to late?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:12 AM
тАО07-21-2000 05:12 AM
Re: Passing parameters to middle of alias script
Berlene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:14 AM
тАО07-21-2000 05:14 AM
Re: Passing parameters to middle of alias script
would only work within a script where $1 was declared. It won't work at command prompt level.
Alias works by substituting the text of the alias for the aliased command itself so typing Z results in the shell executing
cat $1 &
You get ksh: 1: parameter not set because $1 is not set and you have set -u on to warn about undeclared variables. Try man sh-posix.
How does the user intend supplying the name of the file that they want to cat? Would it be Z
If so, and they are really that lazy, just write a simple shell script such as:-
#!/usr/bin/sh
cat $1 &
Hope this helps,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:20 AM
тАО07-21-2000 05:20 AM
Re: Passing parameters to middle of alias script
Your alias didn't work because the shell appends parameter after the whole alias.
Ie.: Z /etc/motd would give:
cat & /etc/motd
That's why you get the errors.
Think you have to create a script for it:
Put a file Z into a directory where PATH looks in with the contents:
lp $* &
And make chmod +x to it.
Regards
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:20 AM
тАО07-21-2000 05:20 AM
Re: Passing parameters to middle of alias script
They did not want to have an extra script.
They did not want to have to add the & at the end of the command line but make it part of the alias. Is that lazy:).
They were going to enter
Z /etc/motd
Remember this is just an example. The real alias is longer in command characters and length of execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:31 AM
тАО07-21-2000 05:31 AM
Re: Passing parameters to middle of alias script
Brian
<*(((>< er
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 05:37 AM
тАО07-21-2000 05:37 AM
Re: Passing parameters to middle of alias script
I thought that's what the forum would reply.
I think this forum is great.
I can try different things and waste a lot of time but when the 'experts' tell me where to go to find something or that my thinking is correct on a solution it make me secure in my thought process.
I would also like to thank HP for supporting this. I am sure it cuts down on support calls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 07:50 AM
тАО07-21-2000 07:50 AM
Re: Passing parameters to middle of alias script
put it into which ever dot file has your alias'
function Z {
cat $1 &
return
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2000 08:04 AM
тАО07-21-2000 08:04 AM
Re: Passing parameters to middle of alias script
YOu do get honorable mention.