curl parameter problem when invoked in script
Hello, i have a problem with curl not executing properly (as in how i'd like it to)
so i use curl to get some files from a portal using cookies and from the command like it's all really simple : Code:
user@host $ curl -b "cookie1=val1; cookie2=val2" -A "Mozilla/5.0" --location http://mysite.com/member.php?page=1 Code:
user@host $ `cat curl | head -n 1` |
Quote:
entered the line exactly as the working example (correct so far?). My question then would be, what have cat and head got to do with anything? Also, as you have not called your script nor entered any parameters, I am a little perplexed by the question topic you have chosen? I feel I have missed something so maybe you could explain further?? |
well, the script goes a little something like this :
Code:
#!/bin/bash Code:
name:mypage.com |
Right, so now we see that the switches are being fed information stored in variables, hence really quite different than what is in the command line example.
Try putting set -xv as the second line of the script and you may be surprised as to what you see is stored in the variables :) On a side note, I will assume the current second line is a typo as of course any spaces around equals sign will cause no end of issues. The second thing I would point out is you do not need cat in any of the invocations where you are using it as grep, or maybe better with awk or sed to also ignore the cut, can easily be used to read a file. I may even suggest that using a bash loop to read the config may have been just as simple :) Let us know how you get on? |
What grail said. awk can completely replace sed (and cut); and both in turn completely replace grep.
http://www.grymoire.com/Unix/Awk.html http://www.gnu.org/software/gawk/man...ode/index.html http://www.grymoire.com/Unix/Sed.html http://sed.sourceforge.net/grabbag/ Also have a look at parameter substitution and other built-in shell string manipulations. You'll find quite often that you don't need any external programs at all. In addition: QUOTE ALL OF YOUR VARIABLE SUBSTITUTIONS. You should never leave the quotes off a parameter expansion unless you explicitly want the resulting string to be word-split by the shell (globbing patterns are also expanded). This is a vitally important concept in scripting, so train yourself to do it correctly now. You can learn about the exceptions later. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes This is probably one of the places you're encountering problems. 2) $(..) is highly recommended over `..` 3) I recommend using a c-style for loop instead of seq. 4) Code:
link=`echo $link$i` This might also be a good place to consider using an array instead. |
thank you alot both of you. in the long run i still have much to go. but the script now works. and i will mark this as solved. thanks.
|
Don't forget to share your solution so others may learn what you have :)
|
All times are GMT -5. The time now is 06:23 PM. |