Kornshell gathering user input question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Kornshell gathering user input question
# 8  
Old 02-17-2011
@apmcd47

"too many implementations of echo for it to be predictable"

try this :

echo "Node: "

In such a simple case (for displaying a simple string without expansion or parsing), as far as i have experienced on FreeBSD, Solaris, HP-UX and AIX, or Linux, the result of this command remains the same so for me the echo command still remains quite "predictable" regarding the display of simple strings.
# 9  
Old 02-17-2011
Quote:
Originally Posted by ctsgnb
@apmcd47

"too many implementations of echo for it to be predictable"

try this :

echo "Node: "
The above would have resulted in the input being on the next line. As he wanted that to be a prompt, with the input being after it, it should have been
Code:
echo -n "Node: "

or
Code:
echo "Node: \c"

or even
Code:
echo -e "Node: \c"

Andrew
# 10  
Old 02-17-2011
@apmcd47

Asking on the same line was not something i was trying to do (if so, i would have used printf)
Of course i agree about -e -n and \c stuff regarding echo, but that was not what i suggested.

I am not saying you are wrong, i am just saying that when i suggested
Code:
echo "Node: "; read var

i didn't care about that cosmetic new line stuff as long as it is harmless as well as the code keeps portative.

But you are true : if you care about it then use printf , i just didn't and don't care Smilie

Last edited by ctsgnb; 02-17-2011 at 07:25 AM..
# 11  
Old 02-17-2011
Quote:
Originally Posted by ctsgnb
Code:
function everything(){

is wrong, you should use parenthesis OR the keyword function , not both
Korn shell :
Code:
function whatever{

}

or POSIX:
Code:
whatever(){

}

I think that was the part that needed to be corrected but I got it working today. Thank you guys very much!!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

2 Loops gathering input

Greetings all, I have came up with some code, to read an input file and generate a list, here is a sample of what I am working with. The variable $USER will be inputted by the person running the utility. do folder=${line%} echo "$folder $USER done < list.txt sample of list.txt- ... (15 Replies)
Discussion started by: jeffs42885
15 Replies

2. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

3. 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

4. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

5. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

6. UNIX for Advanced & Expert Users

Gathering data using SAR

Hi everyone, I would like to ask if it is possible to gather SAR data on a specified time. let say yesterdays report, i want to get data at around 12PM and 5PM. thank you. (2 Replies)
Discussion started by: cwiggler
2 Replies

7. 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

8. Shell Programming and Scripting

A question about the newline character in KornShell scripts

Dear all, How can we know in a KornShell script reading a value from the standard input, that the entered value is the newline character? because as far as I know we cannot use \n for pattern matching. For example: #!/bin/ksh print -n "enter your value: " read VALUE if ] then ... (2 Replies)
Discussion started by: dariyoosh
2 Replies

9. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: ospreyeagle
1 Replies

10. Shell Programming and Scripting

Gathering info on one line

Hi all again, here is the file i am working on : GREIMBAJ00;BAN_CAV;Loader.sh;2003/06/13;17:04:04 GREIMBAJ00;BAN_CAV;Loader.sh;2003/06/13;17:04:06 GREIMBAJ00;BAN_PAK;Loader.sh;2003/06/13;17:04:11 GREIMBAJ00;BAN_PAK;Loader.sh;2003/06/13;17:04:18... (5 Replies)
Discussion started by: HowardIsHigh
5 Replies
Login or Register to Ask a Question