Find the answer to your Linux question:
Results 1 to 5 of 5
I'm getting `sed: -e expression #1, char 35: unterminated s' command` when I try and run the following script. Any ideas? Code: #/bin/bash # # # This script is to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2010
    Posts
    122

    bash, error using sed in my script


    I'm getting `sed: -e expression #1, char 35: unterminated s' command` when I try and run the following script. Any ideas?

    Code:
    #/bin/bash
    #
    #
    # This script is to be used to re-write a configuration file
    # replacing select values, SSID, IP, device name, gateway,
    # and frequency with the supplied command line arguments.
    #
    # example: ./configure input-file, SSID, IP, device-name, gateway, frequency
    #
    #
    FILE=${1}
    SSID=${2}
    IP=${3}
    DEVICE=${4}
    GATEWAY=${5}
    
    sed -e 's/\(wireless\.1\.ssid=\).*/\${SSID}'             \
        -e 's/192\.168\.1\.20$/${IP}/g'                      \
        -e 's/\(NanoBridge M.\)/\${DEVICE}/g'                \
        -e 's/\(route\.1\.gateway=\).*/\${GATEWAY}/g' ${FILE} > /home/garrett/Desktop/NEW-C
    ONFIG.txt
    #END#

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,158
    See my reply to your post in the DaniWeb forums.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Newbie
    Join Date
    Dec 2010
    Posts
    122
    I did. It didn't help. Thanks for keeping on eye out on all fronts though.

  4. #4
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    664
    Looks to me like
    's/\(wireless\.1\.ssid=\).*/\${SSID}'
    is an unterminated s command. No second /.

    I don't undertake to troubleshoot the rest of it.

  5. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    581
    Quote Originally Posted by Garrett85 View Post
    I'm getting `sed: -e expression #1, char 35: unterminated s' command` when I try and run the following script. Any ideas?

    Code:
    #/bin/bash
    #
    #
    # This script is to be used to re-write a configuration file
    # replacing select values, SSID, IP, device name, gateway,
    # and frequency with the supplied command line arguments.
    #
    # example: ./configure input-file, SSID, IP, device-name, gateway, frequency
    #
    #
    FILE=${1}
    SSID=${2}
    IP=${3}
    DEVICE=${4}
    GATEWAY=${5}
    
    sed -e 's/\(wireless\.1\.ssid=\).*/\${SSID}'             \
        -e 's/192\.168\.1\.20$/${IP}/g'                      \
        -e 's/\(NanoBridge M.\)/\${DEVICE}/g'                \
        -e 's/\(route\.1\.gateway=\).*/\${GATEWAY}/g' ${FILE} > /home/garrett/Desktop/NEW-C
    ONFIG.txt
    #END#
    You can not get the value of SSID as you are:
    • attempting to expand a variable inside single quotes --- can be done (also an issue with other expansions as well)
    • Have "back quoted" the '$' when attempting to exand it



    Code:
    sed -f <(echo $"s/\(wireless\.1\.ssid=\).*/\${SSID}/
    s/192\.168\.1\.20$/${IP}/g
    s/\(NanoBridge M.\)/\${DEVICE}/g
    s/\(route\.1\.gateway=\).*/\${GATEWAY}/g") ${FILE} > /home/garrett/Desktop/NEW-CONFIG.txt

Posting Permissions

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