Find the answer to your Linux question:
Results 1 to 2 of 2
Code: #!/usr/bin/expect -f set EXCLUDE "--exclude 'home/dave/fun'" spawn tar -czf /home/backup/dave.tgz -C / home/dave/ $EXCLUDE I will get this error Code: spawn tar -czf /home/backup/dave.tgz -C / home/dave/ --exclude 'home/dave/fun' ...
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    4

    expect problem with set

    Code:
    #!/usr/bin/expect -f
    set EXCLUDE "--exclude 'home/dave/fun'"
    spawn tar -czf /home/backup/dave.tgz -C / home/dave/ $EXCLUDE
    I will get this error
    Code:
    spawn tar -czf /home/backup/dave.tgz -C / home/dave/ --exclude 'home/dave/fun'
    tar: unrecognized option '--exclude 'home/dave/fun'
    Try `tar --help' or `tar --usage' for more information.
    How do I fix the problem with "set EXCLUDE" Do I need to escape -- some how?

    if I do this in shell it works with no problem at all...
    Code:
    tar -czf /home/backup/dave.tgz -C / home/dave/ --exclude 'home/dave/fun'

  2. #2
    Just Joined!
    Join Date
    Nov 2010
    Posts
    9
    It looks to me like the --exclude and 'home/dave/fun' have been combined into a single argument to tar (tar expects the shell to separate arguments into individual strings, it doesn't parse the command line itself).

    Try:
    set EXCLUDE='home/dave/fun'
    spawn tar -czf /home/backup/dave.tgz -C / home/dave/ --exclude $EXCLUDE

Posting Permissions

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