Sponsored Content
Top Forums Shell Programming and Scripting How to create a cron job to take an uploaded filename and move it? Post 302722375 by bull_frog on Friday 26th of October 2012 10:37:32 PM
Old 10-26-2012
Question How to create a cron job to take an uploaded filename and move it?

OK,

So complete newbie here. I would normally do this in PHP or through my FTP program script but I can't in this case (the files are not coming from me, coming from a third party FTP upload).

I have an FTP server (Linux) accepting files coming in from a standard FTP program. Each file will have a unique name like 1a2b.jpg

What I need to do is setup a cron job that does the following:
Reads all the .jpg files in the directory
For each file
parse the filename and get the 1a2b portion
create a subdirectory with the parsed filename = 1a2b
move the 1a2b.jpg file to the 1a2b folder
copy an existing index.html file to the 1a2b folder

Am reading up on shell scripting at present but any help or pointers to threads / info on this greatly appreciated...

Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create cron job automatically?

How do I write a perl script to get the cron jobs? I could do a perl -e ' system "crontab -l > jobs.txt " '; Is there a better way? Then I can use perl to make changes to jobs.txt. How can I submit the changes. I suppose I could use system "crontab jobs.txt", is there a better way? ... (0 Replies)
Discussion started by: siegfried
0 Replies

2. HP-UX

How to create a cron job and run in quality system

Hi Experts, I'm a SAP Basis, I have a small doubt would request you please help on this... 1. I wold like to copy files from one system to another system? as per my knowledge "we have to mount the prod filesystem on the quality box and do a copy every day thru crontab script, or do it via... (2 Replies)
Discussion started by: mahantysk
2 Replies

3. Shell Programming and Scripting

create a chmod cron job help please

hi all, I'm so embarrasingly new; apologies. So here's my dilemma; files are being uploaded to the server via a php script... this is therefore assigning ownership to 'nobody' rather than the account 'user'. It's screwing with the permissions and then the owner can't ftp download images... (2 Replies)
Discussion started by: sirj
2 Replies

4. Shell Programming and Scripting

Re : How to create this cron job?

Hello All, Hope this finds you well. I am creating this shell script that will create cron jobs in crontab file. What I am provided with is the start time , intervals and # of trials. Based of Start time ( say 7:15 am ) and interval being 15 minutes, # of trial being 5 , I should create cron... (5 Replies)
Discussion started by: samshaw
5 Replies

5. Shell Programming and Scripting

Im trying to create a FTP Cron Job

Hello, Im fairly new to this and am hoping for your help in moving forward. 1. I need to carry out a FTP transfer from SERVER1 to SERVER2 at 3am every morning. 2. The FTP is to work on SERVER1 3. There will be many files to transfer (96 files per day) 4. I want to delete the files... (3 Replies)
Discussion started by: nozerf
3 Replies

6. Shell Programming and Scripting

Cron job to move file from one directory to another

Hi, I have following directory structure Media (Inside media directory I have two folders namely videos and images) -->videos -->images Inside media directory I have some video files with extension .mp4 and images with extension of .jpg and .jpeg I want to write a cron job which will... (3 Replies)
Discussion started by: tusharkale
3 Replies

7. Shell Programming and Scripting

i dont want to move files which are being uploaded 5 to 10 min ago

in /abc/jrd/ users are continuously uploading files memo*.txt i have created a memo.sh file in that i have written cd /abc/jrd/ mv memo*.txt /scripts/memo while files are being moved to this /scripts/memo users who are uploading new file are not getting fully copied i this path i want that... (0 Replies)
Discussion started by: rakesh_mumbai
0 Replies

8. UNIX for Advanced & Expert Users

i dont want to move files which are being uploaded 5 to 10 min ago

in /abc/jrd/ users are continuously uploading files memo*.txt i have created a memo.sh file in that i have written cd /abc/jrd/ mv memo*.txt /scripts/memo while files are being moved to this /scripts/memo users who are uploading new file are not getting fully copied i this path i want that... (1 Reply)
Discussion started by: rakesh_mumbai
1 Replies

9. UNIX for Dummies Questions & Answers

Need help to create cron job

Dear Experts, I want to create cronjob with the following steps: 1. go to directory /home/logs/ $cd /home/logs/ 2. copy to /tmp/ the most recent file with "prefix" local_data_ and sufix ".gz" ls -ltr drwxr-xr- 4096 Nov 24 2009 bak drwxr-xr-x 24096 Aug... (6 Replies)
Discussion started by: maxsub
6 Replies

10. UNIX for Dummies Questions & Answers

Create cron job without root

Hi there, I need to create a crone job to backup certain files on my disk without root permissions. Also if I will be able to edit cronetab then I need to know how to edit it with any editor other than vim :mad: (5 Replies)
Discussion started by: aelhosiny
5 Replies
DUPLOAD.CONF(5) 						  Debian Project						   DUPLOAD.CONF(5)

NAME
dupload.conf - configuration file for dupload DESCRIPTION
The configuration file is rather straight forward Perl code as it's included by the dupload script via "do $config". The config file is read as Perl code! Any dupload.conf must begin with "package config;" because "config" is the namespace expected by dupload. For examples of the configuration please refer to the global configuration file /etc/dupload.conf. It contains associative arrays, each indexed by the nickname (see --to option of dupload), for the following items: fqdn [required] The fully qualified domain name (FQDN) of the nickname. method [optional] The transfer method. The available methods are: "ftp" (which is the default), "scp", "scpb" and "rsync" (over SSH). If you are using an upload queue, use FTP because it's fast. If you are using an authenticated host, always use scp or rsync via SSH, because FTP transmits the password in clear text. For scp and rsync to work properly, you have to setup the remote and local host to establish a ssh/slogin connection using .shosts/.rhosts or the files in ~/.ssh/. If you don't want or can't do that, you may find the scpb more convenient since it uploads in batch, reducing the number of password prompts. The only major caveat of the rsync and scpb options is that the files are processed in a batch mode, i.e. not separately, so in case of an error dupload won't be able to detect which part of the transfer failed, and just delete the .upload file completely. login [optional] The account name used to log into the FTP server. The default is "anonymous", should work with firewall logins too. incoming [required] Incoming directory, the directory we try to upload to. queuedir [optional] The directory we move the uploaded files to (after successful upload to incoming. Usually necessary only with some special upload queues. mailto [optional] Email address where the announcement about stable packages is sent. mailtx [optional] Email address where the announcement about unstable and experimental packages is sent. cc [optional] Email address where to send a copy address of the announcement. fullname [optional] Your full name, one that should appear in the announcement; If you leave this setting empty, the default will depend on your mail system. Usually the full name will be copied from the GCOS field in /etc/passwd. visibleuser [optional] Your username that should appear in the announcement. Defaults to "getlogin()". visiblename [optional] The host/domain name that appears as the part to the right of the @ character in the from-part of the announcement. Defaults to the value your local MTA likes. passive [optional] Set the passive mode for FTP transfers. Since dupload uses Net::FTP, you can also use the environment variable FTP_PASSIVE. options [optional] String that will be added verbatim to the command line of any scp or rsync calls done. dinstall_runs [optional] Tells dupload that the remote host runs dinstall (or equivalent) so that dupload won't send a duplicate announcement mail. The default is 0 (false), set it to 1 to enable it. nonus [optional] Tells dupload that the remote host is a valid destination for packages with non-US in their Section field, so that dupload doesn't warn about it. The default is 0 (false), set it to 1 to enable it. archive [optional] If set to 0 (false), adds a "X-No-Archive: yes" header in the announcement. The default is 1 (true). The configuration files also contain the following global variables: default_host [optional] The default host to upload to. The default value of this variable is unset. no_parentheses_to_fullname [optional] Prevents dupload to add parentheses around the full name when making mail announcements. Default is 0 (false), set it to 1 to enable it. HOOKS
Hooks are a powerful way to add actions which will be run before or after a dupload (like the preinst and postinst script of dpkg). You have two sort of hooks: pre-upload and post-upload. Both are simple shell commands (executed by "sh -c" so you can use any shell tricks). Pre-uploads are always run (even in dry mode) and stop dupload if they fail (failure being mesured by the hook's exit status). Post-uploads are only run when you are not in dry mode and only if the uploading succeeded. Both sorts of hooks are run for a given category: changes, sourcepackage, package, file or deb. changes This hook is run once per "changes" file (given as an argument to dupload) with the filename as its parameter. sourcepackage This hook is run once per "changes" file with the source package name and its version as its two parameters. package This hook is run once per binary package (a "deb" file) with the package name and its version as its two parameters. file This hook is run once per uploaded file, with the file name as its parameter. deb This hook is run once per binary package (a "deb" file) with the filename as its parameter. Syntax Hooks are defined in two Perl hashes, %preupload and %postupload, each indexed by category. In addition to the global hashes, each host entry has two fields with the same names, for the host-specific hooks. The shell command will be substituted first: %1 will be replace by the first argument, etc. Per-host or global hooks A hook can be global (for all the hosts) or it can be for a specific host. If there is no specific hook, for a given category, the global one is used. Examples This one runs lintian before uploading. It is global and guarantee that you will always upload lintian-free packages (thanks to lintian return status). $preupload{'deb'} = 'lintian -v -i %1'; This one just display the name and versions of successfully uploaded packages. $postupload{'package'} = 'echo PACKAGE %1 %2 uploaded'; Unlike the two others, this one is specific to one host, master. $cfg{master}{preupload}{'changes'} = "echo Uploading %1"; LOCATION
The configuration is searched as following: /etc/dupload.conf ~/.dupload.conf The latest entries override the former. ENVIRONMENT VARIABLES
Those of Net::FTP for the FTP method: FTP_FIREWALL FTP_PASSIVE AUTHOR
Heiko Schlittermann <heiko@lotte.sax.de> Stephane Bortzmeyer <bortzmeyer@debian.org> dupload 2.7.0 February 2011 DUPLOAD.CONF(5)
All times are GMT -4. The time now is 03:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy