Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
Wonderin if any1 noe hw 2 execute curl command using a script ??? The command i have here is news= " www.yahoo.com.sg" echo curl news | grep "something" | head ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Posts
    59

    executing a Curl command using a script

    Wonderin if any1 noe hw 2 execute curl command using a script ???


    The command i have here is


    news= " www.yahoo.com.sg"

    echo curl news | grep "something" | head "something > data.txt


    but i encounter error like unbound variable


    Can any1 help me Desperately need help =D

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    First of all. can you please try to not use things like any1 or noe.
    Some people here might have trouble reading that.
    And to answer your question:
    Code:
    #!/bin/bash
    news= "www.yahoo.com.sg"
    $grepwhat="something"
    echo curl $news | grep $grepwhat | head $grepwhat > data
    But Id put it in the commands so you wont have to chance to script everytime you run it for something like this:

    Code:
    #!/bin/bash
    echo curl $1 | grep $2 | head $2 > $3
    Here is the first argv you give the address you want to curl.
    the second what you want to grep
    and the thirt what file it has to be put in.

    Hope that helped.
    New Users, please read this..
    Google first, then ask..

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Posts
    59
    Thx but what does this mean ?

    $grepwhat="something"




    Quote Originally Posted by RobinVossen View Post
    First of all. can you please try to not use things like any1 or noe.
    Some people here might have trouble reading that.
    And to answer your question:
    Code:
    #!/bin/bash
    news= "www.yahoo.com.sg"
    $grepwhat="something"
    echo curl $news | grep $grepwhat | head $grepwhat > data
    But Id put it in the commands so you wont have to chance to script everytime you run it for something like this:

    Code:
    #!/bin/bash
    echo curl $1 | grep $2 | head $2 > $3
    Here is the first argv you give the address you want to curl.
    the second what you want to grep
    and the thirt what file it has to be put in.

    Hope that helped.

  4. #4
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Its the value you want to grep for.
    New Users, please read this..
    Google first, then ask..

  5. #5
    Just Joined!
    Join Date
    Jul 2007
    Posts
    59
    Let say i wanna grep the word help from this txtfile, hw am i gonna do it ???$

    $grephelp = "anything i wan" ?


    Quote Originally Posted by RobinVossen View Post
    Its the value you want to grep for.

  6. #6
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Yea, you are correct.
    New Users, please read this..
    Google first, then ask..

  7. #7
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Quote Originally Posted by RobinVossen View Post
    First of all. can you please try to not use things like any1 or noe.
    Some people here might have trouble reading that.
    And to answer your question:
    Code:
    #!/bin/bash
    news= "www.yahoo.com.sg"
    $grepwhat="something"
    echo curl $news | grep $grepwhat | head $grepwhat > data
    But Id put it in the commands so you wont have to chance to script everytime you run it for something like this:

    Code:
    #!/bin/bash
    echo curl $1 | grep $2 | head $2 > $3
    Here is the first argv you give the address you want to curl.
    the second what you want to grep
    and the thirt what file it has to be put in.

    Hope that helped.


    1. This line isn't correct:

    Code:
    $grepwhat="something"
    It should be:

    Code:
    grepwhat="something"
    2. The head command has a numeric option and displays the first -n lines of a file. Read the man page of head.


    Regards

  8. #8
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    heh, whoops sorry.
    I was at work looking at a terminal that was compiling.
    Sorry.
    New Users, please read this..
    Google first, then ask..

  9. #9
    Just Joined!
    Join Date
    Jul 2007
    Posts
    59
    oh.. thx guys

  10. #10
    Just Joined!
    Join Date
    Jul 2007
    Posts
    59
    #!/bin/bash
    #code.h

    shopt -s -o nounset

    news=" Channelnewsasia.com - Singapore News "

    grep header ="haha"

    echo curl $news | grep $header | head -3 | sed 's/<[^<>]*>//g' |tail -1 > $data



    exit




    Need help guys, this is the code im doing on, but after doing the steps given by u guys, i cant the answer i want...how come?








    Quote Originally Posted by RobinVossen View Post
    heh, whoops sorry.
    I was at work looking at a terminal that was compiling.
    Sorry.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...