Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with a unix shell script plz

  • 27-04-2005 8:58pm
    #1
    Closed Accounts Posts: 3,322 ✭✭✭


    Hi guys,

    Im writing a shell script that telnets to websites on port 80 and then issues GET requests and pipes the output back to a file. Something like

    telnet www.bla.com 80
    GET /folder/indexFile.php

    however I cant put GET requests on a line on their own in the shell script because it isn't a unix command?

    Any help appreciated - thanks


Comments

  • Registered Users, Registered Users 2 Posts: 740 ✭✭✭Dero


    Is there any reason not to use wget (or similar)? Seems like it would be a easier solution, though it does assume the presence of something like wget in the first place.


  • Closed Accounts Posts: 3,322 ✭✭✭Repli


    Thank you, will give that a try now


  • Registered Users, Registered Users 2 Posts: 1,459 ✭✭✭seanos


    you could use expect
    handy fer interactive stuffs ...
    telnet blah
    expect 'output'
    send blah
    expect 'more stuff'
    send more

    and so on...


  • Closed Accounts Posts: 365 ✭✭ronanp


    GET /folder/indexFile.php; | telnet www.bla.com 80

    might work perhaps?


  • Registered Users, Registered Users 2 Posts: 78 ✭✭de8o


    Could try..

    (sleep 3; echo username; sleep 3; echo password; sleep 5; echo "GET /folder/indexFile.php"; sleep 3; echo "exit") | telnet www.bla.com 80

    take out username and password if not required and adjust sleep if required


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,755 ✭✭✭niallb


    Hi,
    wget is probably your best answer for this, and expect/autoexpect are designed to help you automate this kind of interaction.
    Try: autoexpect telnet www.bla.com 80 and see what happens.
    You'll need to go through the script afterwards to remove timestamps and other things that will be different session to session.


    To answer your problem of not being able to put GET
    on a line on it's own, the construction you need is
    called a 'here file'. It would look as follows:
    telnet www.bla.com 80 <<EOF
    GET /folder/indexFile.php
    EOF
    

    This starts the command and feeds it everything it reads line by line
    until it reads EOF.

    I still think wget is your best bet in this situation,
    but this is worth knowing.

    NiallB


  • Registered Users, Registered Users 2 Posts: 763 ✭✭✭Dar


    Or just use curl.


  • Registered Users, Registered Users 2 Posts: 1,419 ✭✭✭nadir


    Dar wrote:
    Or just use curl.

    rather fondly refered to as pornget


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    Repli wrote:
    Hi guys,

    Im writing a shell script that telnets to websites on port 80 and then issues GET requests and pipes the output back to a file. Something like

    telnet www.bla.com 80
    GET /folder/indexFile.php

    however I cant put GET requests on a line on their own in the shell script because it isn't a unix command?

    Any help appreciated - thanks

    Use curl or wget or something. The above wouldn't work for virtal-hosted sites or sites that are fussy about HTTP syntax, anyway.


Advertisement