Interactive String


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interactive String
# 1  
Old 06-14-2002
Interactive String

I intend to write a script, where the user will supply the name of the specific string that script should work on.

The first question is how do I accept the string, i.e interactively? and the second question how would the string be refrenced ?

Thanks in advance,

Odogbolu98

Smilie
# 2  
Old 06-14-2002
echo "Hello - enter your string: \c"
read string
echo "Entered: $string"
# 3  
Old 06-14-2002
Thanks usfrog, that works fine.

odogbolu98
Smilie
# 4  
Old 06-20-2002
If you want the string entered in the command line when the script is run... it will become $1.....(you can also accept multiple inputs from the command line with $2,$3......)

So if your script (named my_script) was this:

FIRST_NAME=$1
MIDDLE_NAME=$2
FAMILY_NAME=$3
echo "Your full name is $1 $2 $3! I will call you $1"
echo "Hello $1"

Then you could run the script like this

my_script Peter Michael Herlihy

And it would return

Your full name is Peter Michael Herlihy! I will call you Peter
Hello Peter

Hope this helps....sometimes it's better to prompt during the script..other times it's better having it on the command line...depends on the scripts audience.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automating an interactive process with EOF string

Hello, I'm running Stockfish chess engine ( Home - Stockfish - Open Source Chess Engine ) CLI on Linux in interactive mode which is working fine. root@ubuntu1950x:~# ./stockfish Stockfish 080218 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott setoption name Debug Log File... (2 Replies)
Discussion started by: prvnrk
2 Replies

2. Solaris

New interactive installation

I just took delivery of an Ultra Sparc 60 box. I tried to install Solaris 10 from the cdrom by issuing the following command at ok prompt: ok boot cdrom, and I am getting an error message that says: "Boot device: /pci@1f,4000/scsi@3/disk@6,0:f File and args: can't open boot device. What am I... (2 Replies)
Discussion started by: ijeoma
2 Replies

3. Shell Programming and Scripting

Interactive script – if then

Hi, I am writing an interactive shell script (ksh) but I have no idea how I could make a condition on it : Variables : rep_config="${rep_tools}/_CONFIG" rep_config_old="${rep_config}/_PROTO_OLD" Here is the interactice part : lst_proto=$(cat... (2 Replies)
Discussion started by: Aswex
2 Replies

4. Shell Programming and Scripting

SSH non-interactive

Hi, I want to know how to use SSH non-interactively? I am already able to use sftp -b <batch file> user@host so public/private key set-up already is in place. But my supervisor has told me to use SSH now I want to know how it can be done? I want to do something like: done_files=`ssh ls... (7 Replies)
Discussion started by: dips_ag
7 Replies

5. Shell Programming and Scripting

Interactive script

Greetings gurus I have this simple scripts #!/bin/bash find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" > data_schema find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" >> data_schema <data.schema awk '{print NR, "inVol=" $0, "setDt=4000",... (1 Reply)
Discussion started by: Marjan
1 Replies

6. AIX

Telnet non interactive

Dear all, I need to have shell script which does telnet to another machine with non interactive way like what we do using ftp. Thanks, Shahnaz. (3 Replies)
Discussion started by: shahnazurs
3 Replies

7. Shell Programming and Scripting

non interactive vim

I wanna edit a file non-interactively using vim editor The file contains a line: ACTIVATIONCODE= I have a variable called ACT. I want to edit the file non-interactively using vim such that the concerned line is converted to: ACTIVATIONCODE=contents of the variable ACT ---------- Post... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

8. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

9. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

10. UNIX for Dummies Questions & Answers

Interactive patching?

I would like to ask if anyone knows of a Unix program that is like patch(1), but applies each diff interactively so I can decide on whether to apply a particular diff. This is my situation: someone has made certain changes to a file I created, sent me the modified copy and I would like the... (2 Replies)
Discussion started by: cbkihong
2 Replies
Login or Register to Ask a Question