LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-01-2005, 07:53 AM   #1
bluetwist
LQ Newbie
 
Registered: Jul 2005
Posts: 15

Rep: Reputation: 0
Question About bash


hi,
I really want to write a program constantly watch a directory, if zip file comes in unzip it to another folder.
How can I achieve this by using bash or other scripting language such as perl, python, or ruby? Is there any example?

Thanks for your help!
 
Old 08-01-2005, 08:07 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
pretty easy in bash...

Code:
while [ 1 ] 
do
  if [ -f /somewhere/file.zip ]
  then 
    unzip i_cant_remember_the_options_offhand /somewhere/file.zip
    rm /somewhere/file.zip
  fi
sleep 10
loop
many many mahy ways to do it, someone could do it better than that i'm sure...
 
Old 08-01-2005, 08:09 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
in reality, maybe you only want it to run every few minutes? if so it'd make it easier to just use a cron entry rather than a loop. also i guess it doesn't even matter if the unzip command fail, so just run the unzip regardless and let it fail... who cares?
 
Old 08-01-2005, 08:29 AM   #4
bluetwist
LQ Newbie
 
Registered: Jul 2005
Posts: 15

Original Poster
Rep: Reputation: 0
Smile Thanks

Thanks Chris
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
Bash Echo Kilo Linux - General 3 11-02-2005 11:11 PM
bash help brianbek Linux - General 2 04-03-2005 06:03 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 01:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration