Results 1 to 6 of 6

Thread: Script that print file in a folder

  1. #1
    Join Date
    Oct 2006
    Location
    Argentina
    Beans
    251
    Distro
    Ubuntu 13.10 Saucy Salamander

    Script that print file in a folder

    Hi everyone I am trying to automate everything on my Ubunut Box that works as my server.

    I created a shared folder where everybody drops their docs, txt, pdf and i wanted to know if there is a way to make a script that called with cron, print them every X hours, and them delete them.

    Thanks!

  2. #2
    Join Date
    Jan 2008
    Location
    /us/al/home/mb_webguy
    Beans
    2,339
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Script that print file in a folder

    Sure. The lpr command will print a file. So all you would need to do is write a script that checks for files of specific printable mime types using "file --mime-type -b filename", prints them using lpr, and then deletes them.

    You may want to consider moving the files to a different directory temporarily rather than deleting them. You could have the script run once a day, delete the files from the temporary directory, print the files in the main directory, then move them to the temporary directory. This would give you a day to make sure that the files printed correctly and try to print them again if they didn't.

  3. #3
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,791

    Re: Script that print file in a folder


  4. #4
    Join Date
    Oct 2006
    Location
    Argentina
    Beans
    251
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Script that print file in a folder

    Thanks a lot to both. Its better to move them to temporary dir, mostly are .docs or pdf files.
    I thougt to make a script that look the whole dir prints them moves them. Using cron to call it every 5 hours.

    Thanks for the help!

  5. #5
    Join Date
    Oct 2006
    Location
    Argentina
    Beans
    251
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Script that print file in a folder

    I got my script----but I cant get it to run,
    heres my script.sh
    Code:
    #!/bin/sh
    
    for filename in `ls $Dir'
    do
    
    	if [ -s $filename ]
    		then
    
    		echo 'do you want to print $filename ?"
    		read answer
    
    		if [ "$answer" = y ]
    			then
    			lpr -H localhost $filename
    			mv  $Dir/$filename $Dir/Printed/$filename.old
    
    		fi
    	fi
    
    done
    The asking if I want to print, if check debuggin porpouses.
    When i sh Script.sh I get this Script.sh: 19: Syntax error: EOF in backquote substitution

    What am I doing wrong here..

  6. #6
    Join Date
    Oct 2006
    Location
    Argentina
    Beans
    251
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Script that print file in a folder

    bump...

Tags for this Thread

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
  •