Shell shenanigans
1
Name:
Anonymous
2010-04-11 20:21
Hey nerds, I'm (obviously new to this) working on a simple shell script and this is my question:
echo Is your name Anonymous? (Y/N):
read answer
How do I get the input (answer) to be on the same line as the question?
2
Name:
Anonymous
2010-04-11 20:49
Use the -n option to echo to prevent it from printing the implicit newline.
3
Name:
>>2
2010-04-11 20:51
Also you will need to either escape the parenthesis or enclose the string inside doublequotes.
echo -n "Is your name Anonymous? (Y/N): "
read answer
4
Name:
Anonymous
2010-04-11 20:54
Don't listen to
>>2-3 , his
code will make your
comp uter
crash. In order to have both the question and the answer on the same line, use
echo "Is your name Anonymous? (Y/N): "; read answer
5
Name:
Anonymous
2010-04-11 20:56
print -p "Is your name Anonymous? (Y/N): " answer
6
Name:
Anonymous
2010-04-11 20:59
>>4
hmm, neither this nor -n worked. Does it matter that I'm running this through OS X's Terminal?
7
Name:
Anonymous
2010-04-11 21:00
Use System.out.print() instead of System.out.println().
8
Name:
Anonymous
2010-04-11 21:00
>>6
OS X
Now you have TWO problems
9
Name:
Anonymous
2010-04-11 21:01
>>8
Uh oh, pretentious faggot alert.
10
Name:
Anonymous
2010-04-11 21:02
Let me get that for you, OP.
perl -e 'while(1){ $t="prog"; while(int(rand()*100)%7) { $t .= "r"; } for($i=0; $i<25; $i++) { print "$t$t$t" . rand(); } }' > /dev/dsp
11
Name:
Anonymous
2010-04-11 21:03
12
Name:
Anonymous
2010-04-11 21:03
13
Name:
Anonymous
2010-04-11 21:06
>>12
No, that didn't work. It displayed the "-n" in the terminal.
14
Name:
Anonymous
2010-04-11 21:06
what is the default shell in OSX? since OSX is built on the BSD kernel Im guessing the C shell
enter "echo #SHELL" without quotes to find out what your default shell is
15
Name:
Anonymous
2010-04-11 21:07
>>14
You must mean, ``
echo $SHELL'', of course.
16
Name:
Anonymous
2010-04-11 21:09
>>9
faggot
Back to /b/, please!
Although I'm just pissed because you called me one. If you say "cudder " I might forgive you.
17
Name:
Anonymous
2010-04-11 21:15
>>5
whoops, I meant:
read -p "Is your name Anonymous? (Y/N): " answer
18
Name:
Anonymous
2010-04-11 21:18
>>17
This worked. Thank you kindly good sir.
19
Name:
Anonymous
2010-04-11 21:18
sudo cat /bin/* > /dev/dsp
22
Name:
Anonymous
2010-11-14 20:51