can't call a shell script from within awk

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Luuk
    replied
    use the function 'system(), see man-pages..:'
    Code:
           system(cmd-line)      Execute  the command cmd-line, and return the exit status.  (This may not be available on non-POSIX
                                 systems.)

    Leave a comment:


  • jabbah
    started a topic can't call a shell script from within awk

    can't call a shell script from within awk

    i can execute echo from within awk like so:
    Code:
    echo asdf jkl asdf \
    | awk ' /jkl/ { sub(/jkl/,echo "X(&)") } {print}'
    asdf X(jkl) asdf
    but if i want to execute another shell script
    Code:
    cat ~/bin/doit
    #!/bin/bash
    echo -n KKK
    like so:
    Code:
    echo asdf jkl asdf \
    | awk ' /jkl/ { sub(/jkl/,doit) } {print}'
    asdf  asdf
    it doesnt work.

    at least i found that it is not a path related issue, since
    Code:
    echo asdf jkl asdf \
    | awk ' /jkl/ { sub(/jkl/,echo "("ENVIRON["PATH"]")") } {print}'
    asdf (/home/peter/bin:/opt/bin:/bin:/sbin:/usr/bin:/usr/sbin) asdf
    any ideas how i can make awk execute my ~/bin/doit ?
Working...