Find the answer to your Linux question:
Results 1 to 2 of 2
I get this error ls: cannot access *.sh: No such file or directory while executing "exec ls -l *.sh" invoked from within "set MYLIST [exec ls -l *.sh]" (file "./myls.sh" ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    4

    Expect and ls -l *.sh


    I get this error

    ls: cannot access *.sh: No such file or directory
    while executing
    "exec ls -l *.sh"
    invoked from within
    "set MYLIST [exec ls -l *.sh]"
    (file "./myls.sh" line 2)
    my code for myls.sh
    Code:
    #!/usr/bin/expect -f
    set MYLIST [exec ls -l *.sh]
    puts "$MYLIST"
    exit

  2. #2
    Just Joined!
    Join Date
    May 2009
    Posts
    4
    www:linuxquestions:org/questions/programming-9/expect-and-ls-l-.sh-729020/

    Quote Originally Posted by jlinkels
    This works:
    Code:
    set MYLIST [eval exec ls -l [glob *.sh]]
    The eval expresion is needed to flatten the list produced by glob (so it is explained). If the list is not flattened, the argument passed to ls is ONE file name, with spaces in it, e.g. "file1.sh file2.sh" instead of "file1.sh" "file2.sh". It doesn't ring a bell why eval makes that work right, but it does. As a matter of fact it is a textbook example to use eval here: wiki:tcl:tk/1017

    Also, study this page thoroughly:
    www:tcl:tk/man/tcl8.5/tutorial/Tcl26.html

    jlinkels

Posting Permissions

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