Results 1 to 4 of 4

Thread: cannot create /dev/tcp/localhost/5744

  1. #1
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    70
    Distro
    Ubuntu

    cannot create /dev/tcp/localhost/5744

    Hi,

    I have an application that listens to port 5744. I send to it a command from a terminal like this

    Code:
    echo my-command > /dev/tcp/localhost/5744
    and replies

    I need to built a script doing the job so I make one as simple as this

    Code:
    #!/bin/sh
    
    # $1 = command
    # $2 = hostname
    # $3 = port
    
    echo $1 > /dev/tcp/$2/$3
    then in terminal I write..

    Code:
    sh myscript.sh command localhost 5744
    and I come up with this error

    cannot create /dev/tcp/localhost/5744: Directory nonexistent

    Any ideas?
    Last edited by jambel; December 31st, 2010 at 12:53 PM.

  2. #2
    Join Date
    Jan 2009
    Beans
    Hidden!

    Re: cannot create /dev/tcp/localhost/5744

    The functionality you're trying to use is available in bash, not the POSIX shell, so you need '#!/bin/bash', not '#!/bin/sh'. Try running your existing script with "bash myscript.sh ...". If that works, then just change the "#!" line and it should be fine.

  3. #3
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    70
    Distro
    Ubuntu

    Re: cannot create /dev/tcp/localhost/5744

    So simple?

    thanks man!

    Quote Originally Posted by Brandon Williams View Post
    The functionality you're trying to use is available in bash, not the POSIX shell, so you need '#!/bin/bash', not '#!/bin/sh'. Try running your existing script with "bash myscript.sh ...". If that works, then just change the "#!" line and it should be fine.

  4. #4
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: cannot create /dev/tcp/localhost/5744

    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

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
  •