unix question: user supplied input for 'alias'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix question: user supplied input for 'alias'
# 1  
Old 04-11-2006
unix question: user supplied input for 'alias'

I have a program to scan the log files and I want to pipe the output to 'less'.

I want to create an alias such that following are equivalent

scanlog chunky.lst = /udd/n2man/utils/scanlog chunky.lst|less

where chunky is user supplied file which can change.

Is this possible as an alias or do I need to create a script?

thanks,
OE

ps: Sorry for rather uninformative title.
# 2  
Old 04-11-2006
I do not see (upon looking) where you can do this with aliases in ksh. So I am assuming that you want this as generic as possible.

I am recommending using a function. they work in SH, KSH, & BASH.

One way would be:

logscan () {
/udd/n2man/utils/scanlog $1 | less
}

Better would be:

logscan () {
if [ $# -ne 1 ]; then
echo "usage: logscan: logscan <file>"
return 1
fi
}
/udd/n2man/utils/scanlog $1 | less
}

I make it a habit not to name functions the same name as an existing program. Unless I want to FORCE myself NEVER to use the program.
[Which *is* possible.]
P.S.: There STILL exist some versions of the bourne shell that do NOT recognize functions. If you have one, my heart bleeds for you. Smilie Smilie

Last edited by dsbeerf; 04-12-2006 at 01:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Question: HowTo Exit Script with User Input While Process is Running Mid-Loop?

Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
Discussion started by: hilltop_yodeler
9 Replies

2. UNIX for Dummies Questions & Answers

[SOLVED] how to extract the day and month from a user supplied date ?

Hi All , I am trying to extract the day and month from a user supplied date . But not able . Please help . This is what I am trying to do , I have followed other articles in this scenario. userdate=$1 echo "Script parameter userdate is $userdate" The output of this is in this... (7 Replies)
Discussion started by: megha2525
7 Replies

3. Shell Programming and Scripting

Trouble in getting user input while using CASE statement in UNIX

i want to get user input like this please tell which option to chose 1. mango 2. tango 3. rango if user chooses mango then it should execute a set of statements and again ask like this what do you want to do 1.add 2.subtract 3.exit when i choose exit it should goto my previous menu... (4 Replies)
Discussion started by: s.deepak
4 Replies

4. Shell Programming and Scripting

!!VERY URGENT!! Trouble in getting user input, while using under CASE statement in UNIX

i want to get user input like this please tell which option to chose 1. mango 2. tango 3. rango if user chooses mango then it should execute a set of statements and again ask like this what do you want to do 1.add 2.subtract 3.exit when i choose exit it should goto my previous... (1 Reply)
Discussion started by: s.deepak
1 Replies

5. Shell Programming and Scripting

Validating uppercase/lowercase of user input with perl compared to unix folders

Hi, I need to copy files from a source directory to a destination directory in unix. I'm using the file::copy for the actual copy. The problem is that the source and dest directories are supplied by different users, who might type the name of the directories in various combinations of lower... (6 Replies)
Discussion started by: Furou
6 Replies

6. UNIX for Dummies Questions & Answers

input URL into cmd with a alias

I want to run wget "URL" -SO /dev/null 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:" but I want a alias so I can just type mywget and the URL and it will put the url in the right place and give me the output that I want without having to type that over and over again.:wall: I am newbie to all... (2 Replies)
Discussion started by: splitradius
2 Replies

7. Shell Programming and Scripting

Kornshell gathering user input question

Alright I have a function that does a bunch of commands and then I ask the user for what type of node they are on. So determining which node they are on means they will run a different function. Whats the correct syntax for that? function everything { echo "do stuff" }... (10 Replies)
Discussion started by: Blogger11
10 Replies

8. Shell Programming and Scripting

Unix Shell scripting -How to skip User Standard input section from another script

All, problem Description: For example: I have two shell scripts(executables). let name it as script1 and script2.I'm trying to execute script1 from script2. while executing script2, script1 is asking for manual input(input from keyboard). Now i need to know how I can skip this user input... (3 Replies)
Discussion started by: techie99
3 Replies

9. Shell Programming and Scripting

Newbie Question: Killing a process using a supplied name to a shell script

Hi, I am trying to automate the killing of named processes of which I found a good solution here on the forums but as I am pretty much a begginer to linux I am having an issue. The code I found is: kill $(ps -ef | nawk '/monitoreo start/ { print $2}'} but what I want to do is replace... (3 Replies)
Discussion started by: TylrRssl1
3 Replies

10. Shell Programming and Scripting

Question about user input

Hello all, How can i have a user input that reads like this: echo -n "Please enter a & b:" 10 20 read a read b echo $a echo $b 10 20 right now i have divided it into two echos, like echo -n "a: " echo -n "b: " (1 Reply)
Discussion started by: rrahmegni
1 Replies
Login or Register to Ask a Question