LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2005, 01:12 PM   #1
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Autozipping files from 1 directory & dropping them in other directory ???


Is there any software which can autozip files from "a" directory & place(move) the zipped files in "b" directory ?

This should work like a daemon/service so that everytime a user places his file in "a" directory will be zipped & forwarded to "b" directory.

There have to be some control on flags so that a single file picked from "a" directory should not be picked up again by zipping software.

Can any one suggest ????
 
Old 10-21-2005, 11:44 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use the "-d exdir" option to specify the target directory.

You might want to use the "file" command in your cron script to determine whether a file in the directory is indeed a zip file. There are different types of zip files also, such as those produced by pkzip. Some may be handled by unzip, some perhaps by bunzip. The respective manuals may give details that you need.

Also, it may be a good idea to make sure that the partitions that these files are saved on ( the partitions for both directory A and directory B) are mounted with the "noexec" option. You want to do that for any world writable directory.
 
Old 10-22-2005, 02:36 AM   #3
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Original Poster
Rep: Reputation: 31
Quote:
Originally posted by jschiwal
Use the "-d exdir" option to specify the target directory.

You might want to use the "file" command in your cron script to determine whether a file in the directory is indeed a zip file. There are different types of zip files also, such as those produced by pkzip. Some may be handled by unzip, some perhaps by bunzip. The respective manuals may give details that you need.
................
With which command do i have to use the " -d exdir" option ?

----------------------

I'll tell you my extact situation for which i need help..

Jschiwal , prior to linux we were using novell netware as file & print servers so the file communication(transfer) b/w different centers(offices) we're using print-queues & a seperate inhouse utility was used to transfer these files. We're actually forwarding the contents of these queues.

Like we used a ZIP(inhouse-utility) which 'll zip the files landed at "a" directory & queue these zip files for predefined center & will change the flag of that file so that zip utility wont pick it again.

Now our inhouse product called "datacom" used to send these zipped files to the next hop ( next novell-server) or attached novell servers. Datacom used to take these zipped files which came to the queue.

This was our previous setup & now as we moved to Linux we need the best & optimum solution.

To me ncftp clients stands a good chance for doing background transfers & auto batch job processing.
I tried my hand at zip utility but i guess i need to specify the zip file name every time. Neither i got any examples on net for that purpose.

So what i was looking as a solution to let "ZIP" zipping the files from "a" directory & moving the zipped ones after testing the archive to "b" directory. From "b" directory ncftp picks them n process the transmission for the destined IP/box, i guess ncftp can automate that job of transmission.

Where should i go from here ???
 
Old 10-22-2005, 03:20 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I was referring to an "unzip" option.
Quote:
[-d exdir]
An optional directory to which to extract files. By default, all files and subdirectories are recreated in the current directory; the -d option allows extraction in an arbitrary directory (always assuming one has permission to write to the directory). This option need not appear at the end of the command line; it is also accepted before the zipfile specification (with the normal options), immediately after the zipfile specification, or between the file(s) and the -x option. The option and directory may be concatenated without any white space between them, but note that this may cause normal shell behavior to be suppressed. In particular, ``-d ~'' (tilde) is expanded by Unix C shells into the name of the user's home directory, but ``-d~'' is treated as a literal subdirectory ``~'' of the current directory.
If both locations use Linux, you might want to use tar instead.

I'm not familiar with that ftp program, but there is something I discovered about the ftp command in Linux. At work we changed from Seachange to Adtec ad insertion equipment. All of the spots in the old video library server had to be converted to MPEGs and send to each of the new adtec racks. They use the ftp protocol to transfer files. I was able to take a directory listing of a large number of mpeg files and using sed, I converted the directory listing to an ftp script. The script would connect to the units like this:
ftp username:password@10.10.10.10 < script.ftp

The ftp command would connect with the username and password and would execute the commands in the script "script.ftp". The last command in the ftp script was "bye" so that it would then disconnect and connect to the next rack.

You could have a cron job similar to this:
ftp -i user:password@officeb_ip/path_to_directoryB/ << BYE
mput *.tar.gz
bye
BYE

This script uses a "here" document instead of redirecting input from a script. Instead of reading in lines from a file, the lines are read in from the same script until a line ends in the terminator, which is BYE in this case. The bashref manual would have more details on this.

If the offices are connected via a vpn, you wouldn't even need to bother with all of this. A user in office A could just drop the files into a shared folder. Making a directory write only for "others" would make the directory a Drop Box.

If you don't have a VPN, consider using sftp instead of ftp. The traffic over the net will be take place through an ssh tunnel.

There are other programs to consider, such as curl, wget, rsync.

Good Luck!

Last edited by jschiwal; 10-22-2005 at 03:31 AM.
 
Old 10-22-2005, 03:42 AM   #5
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Original Poster
Rep: Reputation: 31
Leave the ftp part, i'll get it done anyhow after looking for few ftp clients.

Second & most important part about the flags... How can i make my 'zip' utility or 'tar' utility not to pick the file picked earlier again. Like not to zip a file more than once.

I guess there is no flag system for files in linux, which we used to have in dos.
 
Old 10-22-2005, 06:09 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you are using zip, and the outcome is a file with the .zip extension, you can exclude the file from being zipped.

I am not sure if you are wanting to archive and compress a group of files, or just compress a single file. For compression alone, Linux tends to use either gzip or bzip2. Both of these compression programs are used by tar with the -z and -j flags respectively.

The rsync program can be used to handle only new files. That is one way of transfering only new files from one office to another.

The find command is often used with tar to make incremental backups. By only including files after a certain time and date, you could exclude files that are already handled.

Another method could be to have a separate directory for files after they are zipped or tarred, and use that directory to transport the files.


Yet another way would be to enter a processed file into a log file, whenever a file is compressed. This list could be read in during the cron job and used to determine which files to send. There are text tools like "com" that can compare two lists and tell you what the new entries are in the second list for example.

Also, consider running your own mail server. If you need to send some files to someone, just add them as extensions.
 
  


Reply



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
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 11:51 AM
VMware & "directory of C header files" pacranch Amigo 12 05-14-2005 03:39 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
write permissions for directory - not accidently move/deleted the directory linuxgamer Linux - Newbie 10 12-02-2003 03:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:19 AM.

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
Open Source Consulting | Domain Registration