LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 04-11-2005, 04:24 PM   #1
GUIPenguin
Member
 
Registered: Aug 2004
Location: Maine
Distribution: Gentoo Linux
Posts: 239

Rep: Reputation: 30
how can I take input with a shell script?


I need help with taking input with a shell script


something like this

-----> take input ---> save as a var

echo $var

thanks
 
Old 04-11-2005, 04:26 PM   #2
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 316

Rep: Reputation: 30
I think it's something like this, $1 being the first arg.
Code:
if ( "$1" != "" ) set port="$1"
Where port is what you want to name the variable.
Then:
Code:
echo $port
 
Old 04-11-2005, 04:34 PM   #3
GUIPenguin
Member
 
Registered: Aug 2004
Location: Maine
Distribution: Gentoo Linux
Posts: 239

Original Poster
Rep: Reputation: 30
I know how to save it like that.....what I am actualy looking for is to 'take input' from the user and save it in a 'var'. But Thanks
 
Old 04-11-2005, 04:43 PM   #4
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 52
Something like this? (in bold is my input)
Code:
skalkoto@darkstar:~/src$ ./ask_name
What's your name? John
hello John
skalkoto@darkstar:~/src$cat ask_name
#!/bin/bash

echo -n "What's your name? "
read var1
echo "hello $var1"
skalkoto@darkstar:~/src$
The command you are looking for is read.

For more info, look here:
http://www.tldp.org/LDP/abs/html/internal.html
 
Old 04-11-2005, 04:46 PM   #5
GUIPenguin
Member
 
Registered: Aug 2004
Location: Maine
Distribution: Gentoo Linux
Posts: 239

Original Poster
Rep: Reputation: 30
yes........thanks ALOT
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script pipe input - bash mostly laikos Programming 4 11-09-2008 06:14 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
help on shell script as a wrapper to launch default programs according to input file daveiro Programming 2 11-24-2005 05:20 PM
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 04:14 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM


All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration