Thread: Absolute newbie in bash scripting
howdy, everyone!
after break world of scripting, decided have fun bash.
so, kubuntu 11.04 @ hand, wrote piece of code:
now, noticed remember kinda absolutely nothingcode:#!/bin/bash clear echo "welcome megadrive/genesis test script!" echo "please insert path rom(s)" read rom echo "verifying if selected folder exists.." #..theorically. should use pipe here? echo "..done!" echo "" echo "$rom" echo "do want see contents selected folder? (type yes or press enter continue)" read selection if ["$selection" == "yes"]; #if user types yes content of folder shown echo"" cd $rom dir fi echo"" #else script keeps on running echo "insert name of rom" read romname echo "$romname in folder $rom, right? (type yes or press enter cancel)" read selection2 if ["$selection" == "yes"]; cd $rom dgen $romname fi
that's not problem, though, google friend!
so, had found syntax string comparison, but..
wich is, indeed, pretty strange: why bash interpreting command?code:./dgentest: line 22: [yes: command not found
also: how can make script check if folder exists/reprompt it? (i assume there's cycle involved, right?)
whole point of script create script (pretty pointless, know, that's smartest thing can come @ 22:30) wich runs dgen command selected rom.
so, thinking following:
1. push <nameoftheromhere>
(now, can make nano put lines of text direct approach? man file says nothing that..)
2. write actual script inside (eventually asking user parameters (i.e: "do want use opengl renderer? (y/n)")
3. ask user name rename script with
many in advance,
amez
edit: on side note, why can't use (http://img35.imageshack.us/img35/296...eviantidby.jpg) avatar?
resized , it's smaller 64k!
code:echo "verifying if selected folder exists.." if [ ! -d "$rom" ]; echo "$rom not directory" exit 1 fiyou're reading variable selection2, testing variable selectioncode:echo "$romname in folder $rom, right? (type yes or press enter cancel)" read selection2 if ["$selection" == "yes"]; cd $rom dgen $romname fi
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Absolute newbie in bash scripting
Ubuntu
Comments
Post a Comment