Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Shell shenanigans

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?

Name: Anonymous 2010-04-11 20:49

Use the -n option to echo to prevent it from printing the implicit newline.

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

Name: Anonymous 2010-04-11 20:54

Don't listen to >>2-3, his code will make your computer
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

Name: Anonymous 2010-04-11 20:56

print -p "Is your name Anonymous? (Y/N): " answer

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?

Name: Anonymous 2010-04-11 21:00

Use System.out.print() instead of System.out.println().

Name: Anonymous 2010-04-11 21:00

>>6
OS X
Now you have TWO problems

Name: Anonymous 2010-04-11 21:01

>>8
Uh oh, pretentious faggot alert.

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

Name: Anonymous 2010-04-11 21:03

>>10
Looks legit

Name: Anonymous 2010-04-11 21:03

>>2-3

YOU HELPED HIM

Name: Anonymous 2010-04-11 21:06

>>12
No, that didn't work. It displayed the "-n" in the terminal.

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

Name: Anonymous 2010-04-11 21:07

>>14
You must mean, ``echo $SHELL'', of course.

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.

Name: Anonymous 2010-04-11 21:15

>>5
whoops, I meant:
read -p "Is your name Anonymous? (Y/N): " answer

Name: Anonymous 2010-04-11 21:18

>>17
This worked. Thank you kindly good sir.

Name: Anonymous 2010-04-11 21:18

sudo cat /bin/* > /dev/dsp

Name: Anonymous 2010-11-14 20:51


Don't change these.
Name: Email:
Entire Thread Thread List