| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9
Comments:
<0> y0 <1> sup guys.. im just starting bash scripting and i need to know if there is a statement equivilent to and... like if this = that AND this = that then print "blah blah" <0> if [ foo ] && [ bar ]; then echo "blah blah"; fi <0> for example <2> christ <0> always depends on your needs <1> thx man <0> [[ foo && bar ]] <0> also <0> [ foo -a bar ] <0> depends also what foo and bar is <0> native arithmetic: if (( foo < 4 && bar > 3)); then .. <1> im dealing with text.. not numbers soo much <0> [ "$foo" = "text" ] && [ "$bar" = "other text" ] <0> [[ $foo = text && $bar = "other text" ]] <1> if (( foo = "this" && bar = "that")); then echo "bf;lajdf;l"
<0> etc... <0> (()) is math <1> okay <0> [ is the traditional UNIX test command (man test/ help test; [ ] is the same) <1> now in the "$foo" part.. do you really need the quotes...? <0> [[ ]] is bash's replacement of [ <0> yes, you need them <0> [ is a normal command <0> [ this text = this text ] fails <0> because [ arg1 arg2 = arg4 arg5 ] <0> and you want [ arg1 = arg3 ] <0> [ "$foo" = text ] <0> i mean <0> you can't be sure that $foo is without spaces <0> space is the command-argument delimiter in this case. <0> compare echo foo bar to echo "foo bar" <1> okay <1> ill be right back.. gotta restart the system <0> uh <0> windows? <3> i guess so <3> poor fella <1> okay.. back <1> is there anyway that that i can echo something without it going to a new line? <0> help echo <0> man echo <0> (help for the builtin bash echo, man for /bin/echo or wherever it resides on your system) <1> what about shading p***words with *... is that possible? <0> not directly. though, you're always able to write functions that cover your wishes. it's a programming language... <0> however <0> read -s disables the auto echo on your terminal while scanning stdin <0> that comes close to what you asked <1> yeah... thx <1> read -s p*** <- so i would do it like that <0> shading p***words with * is nonsens anyways, as everybody sees how long my pw is - and if he knows me good enough ... etc... <1> if p*** is the variable <0> yea. and $p*** contains the result <1> okay <0> however, "help read" <1> now i dont have to put a $ in the read line correct? <0> no. $foo is always a reference to the content of the variable "foo" <0> it bgets substituted <1> oh okay <0> read wants actually a variable NAME <4> Hi <4> how do I output to a file and print it on screen? <1> http://paste.uni.cc/8837 <5> PumpkinPie: tee <6> eduhat: did you know, that read has a parameter -p "prompt: " (no, you obviously didn't) <0> i referenced "help read" somewhere above IIRC <1> blackpenguin: what do you mean? what would that do.. im gunna go read 'help read' <1> i dont understand... <1> what would the -p param do for me? <0> it's simple english text <7> goes GNU Find have a channel? trying to negate a match, eg find -iregex ".*.(^blahblah).*.cpp" <7> tried the ^ before the (, \'ing the (s, e, using !, etc <1> TheBonsai: what does it do? i dont understand... <8> find -not ... to negate <9> find \! -iregex .... <7> well, i want most of them to match, just wanted to squeeze the following | grep -v down into the regex via negating a certain subpattern. but and -not chained will proably do what i want
<7> theres proably a #pcre or somethign <10> theres #regex i think <7> indeed <7> can i add a callback to be run after every command issued at the prompt (eg, add this command to a history sqlite db) <7> w/o hacking the c source <11> hmm <11> that's an interesting question actually <11> but I can't think of a way how that could be safely done <0> i know one to run BEFORE <0> but not after <10> what done <12> hey guys how do i sent commands to a server once i connect using nc in my script <6> chills: nc reads from stdin <12> blackpenguin, how do i make it read from my script <13> how did you use nc? <12> nc -v www.google.com 80 <12> i want to GET / HTTP 1.0/ <13> it will probably work better with http than random garbage <12> koala_man, nc just stops after it connects <13> google rejects such things <13> and closes the connection <7> chills: wget, curl, libwww-perl, or ruby-net/http are all better than netcat for scripting HTTP <12> koala_man, that was just an example <12> bq, actually i need telnet <13> you're trying to script telnet? <13> using nc? <12> no i just want a bash script that connects to port 23 and commands to the server <12> i am using nc to open the connection <13> nc doesn't stop <13> nc keeps going until the server disconnects <12> koala_man, so how do i send the server commands <13> I won't touch the telnet stuff <12> why not ? <12> insecure <13> if you want something to test nc, try echo -e 'GET / HTTP/1.0\nHost: www.google.com\n' | nc www.google.com 80 <12> right <12> koala_man, yea that worked <12> koala_man, could you explain to me how this worked <9> nc connects to port 80 at www.google.com. Then it sends to lines / commands to Google's web-server: First line is the GET / command (to get the default page) using the HTTP v. 1.0 protocol. <12> isnt it :| in the wrong order <9> The Host: www.google.com is just iceing on the cake, telling the server (in case it wasn't sure which server itself is) that we want the default page for www.google.com. <12> right <13> what order <12> like shouldnt we first connect and then send the command <13> nc won't send anything until the connection is established <12> oh right <9> If can do this instead: ( sleep 2; echo GET / HTTP/1.0; sleep 2 ) | telnet www.google.com 80 <12> right <12> echo -e ' p***word/n' | nc www.google.com 23 <12> should work ? <11> could, yes <12> hmm <11> (provided they run telnet server;) <12> it wasnt google :p <12> but yea worked <12> how would i give 4 different commds echo -e ' chills/n' 22342/n whereis bla /n | nc www.google.com 23 <11> you probably want to wait for a proper reply? <12> ah yea <11> then welcome to the hell of network coding in bash using netcat <11> :) <11> I didn't figure out a better way than three processes... a) read from a fifo | b) netcat | c) parse output and feed commands to the fifo <12> right <11> g'night <9> What is wrong with netcat and expect ? <12> my first and second commands are wroking <12> third isnt <9> Guessing - the third command is being sent before the receiving process is ready. <11> MiniMax: expect is neat, but you've got posix shell next to anywhere -- you're not as fortunate with expect <9> Hence you have to use a few sleep's. <11> or wait for reply <11> :) <11> using sickmethod viz above <11> okay, I'm going to sleep as well <12> yea making it hold for a feew seconds should work
Return to
#bash or Go to some related
logs:
#ldap #sdl friedman101 AuthOptions requires SASL support (-DSASL)
fc5 tightvnc-server yafumoto nomuryto beatles+white album+vynil record BAIRC bash +sitecustomize +py2exe
|
|