Topic "using call to produce dynamic file names"

Author Message
sales@rwb.com.au
[View user's profile]

Joined: 2006-04-24
Posts: 2
Location: Australia
Hi all,
I'm using a script that uses `call` to dump a database:
call mysqldump mydb | gzip > /tmp/mydb.sql.gz
this works just fine. But, what I would like is to call the file with a date/time tagged with it. e.g
call mysqldump mydb | gzip > /tmp/mydb_23-04-06_11-23am.sql.gz
of course the 23-04-06_11-23am part needs to be automated.
I can do this by calling a shell script e.g call foo.sh but I was wondering if there were any linux shell gurus who might be able to help me do it straight from the winscp call syntax.
Something like:

option batch on
option confirm off
option transfer binary
call datevar=date '+ %d_%m_%y__%H-%M'
call mysqldump mydb | gzip > /tmp/mydb_$datevar.sql.gz
get /tmp/mydb_$datevar.sql.gz c:\backupfolder\
close
exit

ANOTHER alternative would be to always dump it as the same name in /tmp then do a
`call rename samename namewithdynamicdate
then get it. But alas I can't do this other than in a .sh file , so a solution here is just as sufficient.

thanks
sam
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
I'm not a linux guru Smile but you can try following:
call mysqldump mydb | gzip > /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz
_________________
Martin Prikryl
sales@rwb.com.au
[View user's profile]

Joined: 2006-04-24
Posts: 2
Location: Australia
mysqldump test | gzip > /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz
bash: /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz: ambiguous redirect
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
sales@rwb.com.au wrote:
mysqldump test | gzip > /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz
bash: /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz: ambiguous redirect

Well, it works for me, at least on command-line. I haven't tried that via "call".
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License