UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 7th, 2004, 10:13 AM
timlograsso timlograsso is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 26 timlograsso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 18 sec
Reputation Power: 0
Script generates unique filname automagically?

Hi everyone,

I need to write a script that executes a command with one of the paramaters (filename) being uniquely generated at script execution time. Something to the extent of: pgdump -f DBxxxxxx DBNAME I just need to be able to put that xxxxxx part in dynamically, possibly based on date/time. Any ideas?

--Tim

Reply With Quote
  #2  
Old September 7th, 2004, 10:37 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 44 m 45 sec
Reputation Power: 9
it's depending of what 'a script' is...
in a shell use: xxx.YYYYMMDDHHmmSE.PID
(i hope you are familiar)
this takes a week but it works.

if it's not a stupid shell, but a program (c, c++, perl ...)
you sure can find a function called 'mktemp' or 'mkstemp'

google 4 man pages

Reply With Quote
  #3  
Old September 7th, 2004, 11:07 AM
timlograsso timlograsso is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 26 timlograsso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by guggach
it's depending of what 'a script' is...
in a shell use: xxx.YYYYMMDDHHmmSE.PID
(i hope you are familiar)
this takes a week but it works.

if it's not a stupid shell, but a program (c, c++, perl ...)
you sure can find a function called 'mktemp' or 'mkstemp'

google 4 man pages


I just created the following script:

Code:
_base_path="dbexport"
_file_date=`date +%Y%m%d%H%M%S`
pg_dump -f "$_base_path/ETADB.$_file_date.$$" ETADB
pg_dump -f "$_base_path/MNDB.$_file_date.$$" mn


This dumps two databases I need into something archiveable on a daily basis.

Thanks,

--Tim

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Script generates unique filname automagically?


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway