Results 1 to 6 of 6

Thread: Linux bash script for telnet connection

  1. #1
    Join Date
    Aug 2010
    Posts
    55

    Linux bash script for telnet connection

    Hello,
    I'm looking to make a bash script that connects with telnet running a command on the remote server and retrieve the file created (It has limit, I can open a ftp connection to retrieve the file behind). And more information is passed as parameter of the program:
    Code:
    test_prog.sh <serveurdist> <login> <passwd> <deb>
    I have it but it does not work (I think I'm missing the options to connect directly without requiring authentication to connect to the server. Any help regarding this will be appreciated. Thank you.

  2. #2
    Join Date
    Sep 2005
    Posts
    1,370

    Re: Linux bash script for telnet connection

    Tip to execute a command on a remote server, when that was accessible from a telnet but can not want to put services (rlogin, rsh, rexec) in place
    on the remote server.

    1) Make a script containing the transactions would be done manually
    by telnet. (Example Script action.scr "below)
    Code:
    # / Bin / sh 
    sleep 2 
    echo "user connection" 
    sleep 1 
    echo "password" 
    sleep 1 
    echo "command 1" 
    sleep 1 
    echo "No Control" 
    sleep 1 
    echo "exit"
    Note (1): The "sleep 1" is important on Linux platforms otherwise the script is too fast is the telnet sees not pass the instructions. Increase the value of sleep following the order if it a long delay in reply.

    Note (2): Do not forget to put the rights of execution on the script (chmod 777 action.scr)

    2) Then run the script redirects to the telnet
    Example:
    Code:
    Action.scr # sh | telnet IPaddress
    Result: telnet connection with enforcement of orders 'echo "order"'
    script "action.scr" (as manual way ").

  3. #3
    Join Date
    Aug 2010
    Posts
    55

    Re: Linux bash script for telnet connection

    The problem I have for the moment that it can not authenticate correctly. I manage to access the server, but it puts me directly after the remote server terminated the connection (it does not even that). Otherwise like find walking very well, I already tried everything in hand and everything works.

  4. #4
    Join Date
    Apr 2008
    Posts
    3,424

    Re: Linux bash script for telnet connection

    I proposed to the rexec instead of your telnet:
    Code:
    rexec [username @ hostname] [-DNN] [-l username] [-p password] command
    And command, you put
    Code:
    "Cd $ 4; find.-Type d-exec echo () \;> arbo.txt"
    This should work. Do not worry about not being noticed you just go with your code.

  5. #5
    Join Date
    Aug 2010
    Posts
    39

    Re: Linux bash script for telnet connection

    Even i have a similar kind of a issue with my script, well then I tried in every way - in case I made a mistake - I checked what I typed several times and I read the man with extensively.
    So I have this code:
    Code:
    echo "test" root @ sertst rexec-l login-p passwd "find.-type> arbo.txt" echo "End Test"
    But it asks for more password and answer me this:
    Code:
    Password: rexec: Error in rexec system call rexec: (The system error FOLLOWING Itself May Be in error) rexec: Success
    I have no idea regarding this error, if you can help me with this it would be great.

  6. #6
    Join Date
    Dec 2005
    Posts
    945

    Re: Linux bash script for telnet connection

    Hello,
    I know that I tried to telnet like this and finally I am back on the rexec. But I think there are limitations and different versions of the OS according to rexec, including the fact of passing the password parameter. I guess I am correct here and you have understood what I am trying to say.

Similar Threads

  1. How to create CGI script in bash?
    By Mulan in forum Software Development
    Replies: 5
    Last Post: 01-09-2010, 08:19 PM
  2. Linux bash script with the command w
    By Trini Alvarado in forum Operating Systems
    Replies: 4
    Last Post: 22-03-2010, 12:11 PM
  3. Create bash script for ftp
    By teenQ in forum Operating Systems
    Replies: 4
    Last Post: 04-03-2010, 07:37 PM
  4. Bash script for internet connection in Ubuntu
    By Callium in forum Operating Systems
    Replies: 5
    Last Post: 23-01-2010, 05:42 PM
  5. Bash script if then else help
    By Unix'EM in forum Software Development
    Replies: 3
    Last Post: 18-08-2009, 06:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,706,004.28684 seconds with 17 queries