The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to cut data block from .txt file in shell scripting pank29 UNIX for Dummies Questions & Answers 6 04-25-2009 03:05 PM
data formatting in Unix shell Scripting regnumber Shell Programming and Scripting 1 10-04-2008 06:45 PM
converting a tabular format data to comma seperated data in KSH Hemamalini UNIX for Dummies Questions & Answers 2 06-16-2008 05:37 AM
how to verify that copied data to remote system is identical with local data. ynilesh Shell Programming and Scripting 3 01-31-2008 08:55 AM
Howto capture data from rs232port andpull data into oracle database-9i automatically boss UNIX for Dummies Questions & Answers 1 09-23-2007 03:35 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2009
voltaza voltaza is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 8
Lightbulb Scripting data, day after

Hi there,

Im having a problem with my script... dont now how to finish.

I have a more than 50 files in folder where is myscript. I manage to make this script work but i have a problem with files i want to send. We talk about .log files. My script look like this:


Code:
#!/bin/sh.
more subscriber.log | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

but i have a problem because i dond need subscriber.log i need subscriber.log from day before etc. subscriber.log.2009-08-15 and it should be generated for every day but a date should be from yesterday.

my log looks like this:

Code:
subscriber.log.2009-08-13
subscriber.log.2009-08-14
subscriber.log.2009-08-15

my script should also do the grep and the FTP but i manage to do this, i just dont know how to force this script to take log file form yesterday.


please help, and thanks

sincerly yours Voltaza

Last edited by Franklin52; 08-21-2009 at 08:28 AM.. Reason: adding code tags
  #2 (permalink)  
Old 08-21-2009
sagar_evc sagar_evc is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 30

Code:
find <directory> -mtime +1 -name <pattern of the file name> -exec ls -el {} \;

This command should give you the file created a day earlier. You cut the file name field and use in your script.

S

Last edited by Franklin52; 08-21-2009 at 08:28 AM.. Reason: adding code tags
  #3 (permalink)  
Old 08-21-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,323
Both of you, please read the following, ty:

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
  #4 (permalink)  
Old 08-21-2009
voltaza voltaza is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 8
Thanks mate,

but i dont know where to put this line? before grep ? Is this the first line in my script? I also have to automate this script so it can work every day... i need that this script use log file from yestrday from all logs in this dir.

cool zaxxon. tnks

Last edited by voltaza; 08-21-2009 at 08:31 AM..
  #5 (permalink)  
Old 08-21-2009
sagar_evc sagar_evc is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 30

Code:
#!/bin/sh.
find <directory> -mtime +1 -name subscriber* -exec ls -el {} \; >> temp.file
#cut the last field to get the file name and assign it to a variable filname
more $filname | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

  #6 (permalink)  
Old 08-21-2009
voltaza voltaza is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 8
this code give me log file from today 21 and i need a file from yestrday subscriber.log.2009-08-20 my last field is subscriber.log and no date...


Code:
#!/bin/sh.
find <directory> -mtime +1 -name subscriber* -exec ls -el {} \; >> temp.file
#cut the last field to get the file name and assign it to a variable filname
more $filname | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

  #7 (permalink)  
Old 08-21-2009
voltaza voltaza is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 8
Quote:
Originally Posted by sagar_evc View Post
Code:
#!/bin/sh.
find <directory> -mtime +1 -name subscriber* -exec ls -el {} \; >> temp.file
#cut the last field to get the file name and assign it to a variable filname
more $filname | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd
this code give me log file from today 21 and i need a file from yestrday subscriber.log.2009-08-20 my last field is subscriber.log and have no date... This log i generated just now and a dont need log from today... i need a log from 2009-08-20

---------- Post updated at 01:44 PM ---------- Previous update was at 01:34 PM ----------

? help

---------- Post updated at 01:56 PM ---------- Previous update was at 01:44 PM ----------

I dont need last file... i need file before that....

Last edited by voltaza; 08-21-2009 at 08:40 AM..
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0