LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2011, 07:26 PM   #1
Rameses
LQ Newbie
 
Registered: Jul 2010
Posts: 13

Rep: Reputation: 0
batch script


I'm trying to create a script that will look for a "filename" under /etc/, date stamp the file and copy it to /var/www/upload
 
Old 07-14-2011, 07:28 PM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,811
Blog Entries: 1

Rep: Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191Reputation: 1191
Nice... and what have you done so far?
 
1 members found this post helpful.
Old 07-14-2011, 07:41 PM   #3
Rameses
LQ Newbie
 
Registered: Jul 2010
Posts: 13

Original Poster
Rep: Reputation: 0
still new to bash

Quote:
Originally Posted by sycamorex View Post
Nice... and what have you done so far?
if [ ! -f "$filename" ]
then
echo "$filename doesn't exist"
else
echo "$filename exists"
do
touch "filename"
scp /var/www/
fi
 
Old 07-14-2011, 08:20 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
1. put the code in code tags for ease of reading
2. lose the 'do'; that's for loops
3. to automate the scp you'll need to use ssh authorised keys
4. why are you timestamping the file (with touch); what are you trying to achieve?
The timestamp will vary as the file gets moved/read etc. If you want to preserve the timestamp, you'll need to append it to the filename eg file.ext.20110715
http://www.unix.com/tips-tutorials/2...ime-atime.html
 
Old 07-14-2011, 08:23 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Well except for the 'do', which doesn't do anything, the rest looks ok

For LQ the only thing to remember is to put your code in [noparse][code][/code][noparse] tags.
 
Old 07-14-2011, 08:36 PM   #6
Rameses
LQ Newbie
 
Registered: Jul 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you for all your help
 
  


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
batch script help for backups investmentbnker75 Programming 5 11-26-2008 12:19 PM
script help for batch processing mma8x Linux - General 5 12-08-2006 02:31 AM
Change batch script to shell script alan.belizario Programming 5 03-31-2005 01:41 AM
Change batch script to shell script alan.belizario Linux - Software 1 03-30-2005 02:49 AM
Batch mv and tr script ... OrangeWarp Linux - General 1 12-11-2002 06:14 AM


All times are GMT -5. The time now is 11:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration