Find does not work in Expect Send command

Help
Sharjeel
2010-03-27
2013-05-02
  • Sharjeel

    Sharjeel - 2010-03-27

    I run this bash command to display contents of somefile.cf in a Weblogic domain directory.

    find $(/usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print $2}' | sed -e 's/weblogic.policy//' -e 's/security\///' -e 's/dep\///' | awk -F'/' '{print "/"$2"/"$3"/"$4"/somefile.cf"}' | sort | uniq) 2> /dev/null -exec ls {} \; -exec cat {} \;
    

    I guess it needs some more escaping of special characters or probably I dint escape the existing ones correctly. Any help would be appreciated.
    I tried incorporating this in an expect script and also escaped some special characters and double quotes too but it throws an error "extra characters after close-quote"

    send "echo ; echo 'Weblogic somefile.cf:' ; find \$(/usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print \$2}' | sed -e 's/weblogic.policy//' -e 's/security\\///' -e 's/dep\\///' | awk -F'/' '{print \"/\"\$2\"/\"\$3\"/\"\$4\"/somefile.cf\"}' | sort | uniq) 2> /dev/null -exec ls {} \\; -exec cat {} \\;
    
     
  • Sharjeel

    Sharjeel - 2010-03-27

    My expect lines got printed twice.Please refer this

    send "echo ; echo 'Weblogic somefile.cf:' ; find \$(/usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print \$2}' | sed -e 's/weblogic.policy//' -e 's/security\\///' -e 's/dep\\///' | awk -F'/' '{print \"/\"\$2\"/\"\$3\"/\"\$4\"/somefile.cf\"}' | sort | uniq) 2> /dev/null -exec ls {} \\; -exec cat {} \\;

     
  • ender

    ender - 2010-03-27

    I'm curious what the escape sequence should be so I'm going to try it later but you should try capturing it with autoexpect first. It should escape everything exactly like it needs to be.

     
  • Larry W. Virden

    Larry W. Virden - 2010-04-07

    Wouldn't it be easier to put that pipeline into a bash script, then use expect to run the bash script? Then there is no dealing with the escaping characters at all.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks