Results 1 to 3 of 3

Thread: Bash script error

  1. #1
    Join Date
    Jul 2007
    Location
    Florida
    Beans
    101
    Distro
    Ubuntu 12.04 Precise Pangolin

    Bash script error

    I'm posting this in hopes that someone can help me solve my dilemma. I have created a script which I found in the following link: http://www.labnol.org/software/print...n-linux/17841/
    This is supposed to enable moving a file to a Dropbox folder named PrintQueue and then have it sent to a remote printer when the script runs. The script is giving me problems. I have attached the script and also a screen print of the error message that I receive whenever I attempt to run the script. If anyone can see what is wrong with this script, I would greatly appreciate any assistance in resolving the problem.
    Thanks,
    Richard Mockler
    Attached Images Attached Images
    Attached Files Attached Files
    HP 220-1050XT, Intel(R) Core i5 2400S Quad CPU @ 3.3 GHz, 6Gb DDR3 Ram, 1Tb HD, AMD Radeon HD 6450 Graphics 1Gb, 21.5" LCD, Beats Audio

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,243
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Bash script error

    missing ; before do

    frankly that script is full of fail, it has at least 3 things seriously wrong in 6 lines of code total
    - using ls: ls is for human eyes not for scripts
    - ls-ing the dir only to merge it with the filename later
    - redefining IFS to avoid problems with spaces

    all of these are non-issue if one uses builtin globs
    Code:
    #!/bin/bash
    
    PrintQueue="/root/Dropbox/PrintQueue";
    
    for PrintFile in "$PrintQueue"/*
    do
      lpr -r "$PrintFile"
    done
    Last edited by Vaphell; October 25th, 2012 at 03:28 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Jul 2007
    Location
    Florida
    Beans
    101
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Bash script error

    Vaphell, my sincere gratitude for your help. Your suggestion and your attached script worked perfectly for me. I simply did a copy, paste of your script, set the proper path of my Dropbox/PrintQueue folder, set up a cron job to run the script every minute, and now remote printing works exactly the way I want.
    Thanks again,
    Richrd Mockler
    HP 220-1050XT, Intel(R) Core i5 2400S Quad CPU @ 3.3 GHz, 6Gb DDR3 Ram, 1Tb HD, AMD Radeon HD 6450 Graphics 1Gb, 21.5" LCD, Beats Audio

Bookmarks

Posting Permissions

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