Button to Zip, then Blowfish, then FTP?

Hi - I'm completely new to DOPus, but I am finding it really cool. I'm using a japanese system so there are some hiccups with the unicode side of things but most stuff is working ok, it seems!

That said, I'd like to make a button to do the following against selected files or folders -

Create a zip with a specific filename -
string-ymd.zip

Copy the selection to the zip.

Use a command line blowfish encrypter -
clbf.exe -e -p somepass string-ymd.zip string-ymd.bf

Copy the encrypted file to an FTP site for backup.

I can't figure out how to make a variable (the filename is one candidate), or even just add files to the zip.

In one button, I tried:

CreateFolder ZIP NAME=./Rick{date|yyyy-MM-dd}.zip
Copy ADDTOZIP TO=./Rick{date|yyyy-MM-dd}.zip
... but it just errored out after creating a blank zip file. Maybe I need to use ADDTOZIP to create the zip, and then rename it how I like?

I can't find any syntax listing, so this is a bit hit and miss. Is there a tutorial somewhere? Could someone be so kind as to give me a couple of tips? Thank you in advance.

Sincerely,
Rick

[quote]
RickCogley wrote:
....
Create a zip with a specific filename -
string-ymd.zip

Copy the selection to the zip.
....
CreateFolder ZIP NAME=./Rick{date|yyyy-MM-dd}.zip
Copy ADDTOZIP TO=./Rick{date|yyyy-MM-dd}.zip
... but it just errored out after creating a blank zip file. Maybe I need to use ADDTOZIP to create the zip, and then rename it how I like?
....

Sincerely,
Rick[/quote]

Hi Rick,
Congrats ! Your post ruined my evening !

I can do this much (without resorting to Dos):

Right mouse button function does this.
CreateFolder ZIP NAME=Rick{date|yyyy-MM-dd}.zip
Left Mouse button does this:
Copy TO .\Rick{date|yyyy-MM-dd}.zip

This will append only.

That's all I have tonight.
Good Luck.

                                  Sincerely,
                                  Tsunami

thanks Tsunami. Maybe I need :

.\

and not

./

because mine is just crashing left and right...

In Downloads/Tools on this site, there is a doptest.exe you can download and drag to a toolbar in customize mode. I am finding this useful for testing the various parameters you can pass to commands, just to see what is getting passed. Also, if I have to do this all in a batch file, doptest.exe will help me test the %1 etc parameters getting passed to the batch. Check it out if you have not already.

--R

Well Rick,
Thanks much for your post.

In PHP ./ ../ are among the first things I think of,
but your slip saved me here. I might not have it if you didn't say that.

Drag and Drop doptest.exe to a toolbar?
I think you really meant to run it under Dos in a button
followed by the options ( I used 2 ) and then the commands or whatever.
I really hadn't tried it before today.
I had been looking at the windows\temp dop Dos bat files. However, Doptest helps both in Dos and Opus.

But, try this:
Drive:\path\doptest.exe 2 {allfilepath$}
Select alot of files and press the button.
It should error out after the Dos line charcter limit is reached.

A better method is program support to import a line by line text file.
Happily, Dopus really doesn't need this yet.

Much has been posted on this forum in the past day pointing to the end you originally sought .

Do you have a command line program for blowfish?
How does it save the key?
I'd really like to know.

Sincerely,
Tsunami

Yep, I just switched DOpus to Configure mode by choosing Configure from the context menu on the toolbar, found the doptest.exe file, dragged it right onto a toolbar I had created for testing. I just used the defaults after DOpus auto-created the button.

The two lines just below are working to zip, in the button -

cd C:!SystemUtilities
C:!SystemUtilities\zipit.cmd JRC-{date|yyyyMMdd}.zip {sourcepathshort$}.

... where pkzip is in my path and the zipit.cmd contains:

==
echo off
pkzip -a -r %1 %2

I am trying to use MySecret.exe, freeware, to encrypt -

MySecret -e -p SomePassword infile outfile

The obvious problem is that the password is in cleartext. But I just want to protect my files after they are on the ftp server.

Now, I have two challenges I am working through -

  1. if I put both the pkzip and the mysecret commands inside the one batch, the path of the created zip file is not stored so when I use the same variable to try and create the blowfish file, it gives a "file not found".

  2. if I put both commands in a button, so that I can use the same parameter contents, the mysecret part errors out because the initial zip is not yet made - no input file. The two commands are executed simulataneously and I am not sure how to make them go "in serial".

I made a batch file blowencrypt.cmd to control the mysecret encryption -

==
echo off
MySecret -e -p SomePassword %1 %1.bf

Regards
Rick

Here's what I have so far, which seems to be working at least up to the encrypt part -

[DOpus.ButtonInfo]
Name=zipnblow
Icon=71
Flags=8,0,1
Color=0,a0a0a0
IconFile1=C:\WINDOWS\System32\shell32.dll,71
Tooltip=zipnblow
Func1=cd C:!SystemUtilities
Func2=C:!SystemUtilities\zipnblow.cmd c:\temp\RC{date|yyMMdd}.zip {sourcepathshort$}. c:\temp\RC{date|yyMMdd}.zip.bf

The batch file zipnblow.cmd looks like:

===zipnblow.cmd===
echo off
pkzip -a -r %1 %2 && MySecret -e -p somepass %1 %3

How this works - I used the && directive between the pkzip and MySecret commands, which means, "do the second if the first succeeds". This forces the two commands to be executed in serial. This is only available in NT-based systems and is not in Windows 9x. Also, I think the batch you use has to be a .cmd not a .bat for these advanced things to work.

The result is, I get the zip and the blowfish file both in the c:\temp directory.

Now I need to figure out two things:

  • how to do this same thing with "native" commands if such a thing is possible.
  • how to copy the bf file to my ftp site for storage.

Possible?

Regards
Rick

An alternative -

===========zipnblow2.cmd============
echo off
pkzip -a -r %1 %2 && ChilkatZipSE.exe -encrypt 128 -password SomePass %1

You can use the Chilkat Zip to Self Extracting encrypted archiver, which is freeware too. That way, the file is encrypted and you donT need blowfish etc installed on the target machine.

FWIW.

Regards
Rick

Yes, I understand how you're using && here.
The My Secret commands are only executed if the exit code from pkzip is true.
I've used this under Win98 running 4DOS many times.
I don't have a laptop and needed a cheap method of transferring data from my Digicam on the road.
I added a USB2 card to an old junk PIII I rebuilt, plugged a minimouse into the inside port of the USB2 card,
and velcroed the mouse to the inside of the case.
A "blind" Digicam Data station was thus made. It runs on 4Dos and Win98 SE .
It uses no monitor; It just plays a few sounds.
I use batch files to find the CRC's of all the pictures, find true free space on the hard drive(s) partitions by proving cluster sizes on the flash card.
I then copy the flash card to a Time SubDir of a Date Dir.
I then prove the bytes added to the Hard Drive equal the bytes on the flash card,
plus the bytes for the Date Dir and the bytes for the Time SubDir.
I then verify the CRC's of the copied pictures from a text file I made.
If all the CRC's are not valid, _err is appended to the crc textfile and the beep cope is modified.

verifyCrc.exe crc.txt || ( rename/q crc.txt crc_err.txt && set beepcode=4 )

I downloaded MySecret and I'm looking into it.
I've read through your ideas and you are quite well along on this now. I understand, but I'm more familiar with 4Dos and Take Command. Often however, the syntax reduces to MS Dos in the end.

I'll try to see what I can do with this. I'll then let you know my findings.

                                 Regards,
                                 Tsunami

Neat syntax. I'll have to remember that. Thanks for the extra tidbit.

-R

OK, it's working, thanks to the DOpus team and Tsunami's help. The button I have is this, and you can copy this text to the clipboard, and then just copy it right to a toolbar in DOpus in Configure mode, if you like:

[DOpus.ButtonInfo]
Name=Zip Encrypt FTP
Icon=71
Flags=8,0,0
Color=0,a0a0a0
IconFile1=C:\WINDOWS\System32\shell32.dll,71
Tooltip=Zip Encrypt FTP
Func1=cd C:!SystemUtilities
Func2=sync:C:!SystemUtilities\zipnblow.cmd c:\temp\RC{date|yyMMdd} {sourcepathshort$}.
Func3=Copy c:\temp\RC{date|yyMMdd}.exe TO ftp://backup%40mydomain.net:somePasswor ... rc-backup/

Of course, change the references to your own paths etc. And, the batch file the button calls is this:

===========zipnblow.cmd============
echo off
pkzip -a -r %1.zip %2 && ChilkatZipSE.exe -encrypt 128 -password somepass %1.zip

Tricks:

  • Set the button as "standard function" not DOS batch.

  • Since pkzip is an old DOS program, use {sourcepathshort$} to force an 8.3 filename, and pipe this into the batch as an arg - %1, %2 etc. Further, pkzip did not like it when I added the time to the date, so keep the filename short. Perhaps I'll revisit with a more versatile commandline zip program.

  • Within the batch, use && to execute the pkzip, and then only when that finishes successfully, execute the encryption. FYI, there is also || which is the opposite - only if the first fails execute the second.

  • Within the batch, the (freeware) ChilKatZipSE.exe makes an EXE file of the same name as the zip, but switches the zip extension for exe. Google for this exe name and "command line" for the syntax, as it is not in the help.

  • Notice the "sync:" on line two of the commands in the button. This says "wait for this line to finish before going to the next line". If you don't do this, the button will execute the batch which zips and encrypts and the copy to ftp simultaneously - and the copy command will not find its source file. For reference, the equivalent to this in a simple NT batch file is to put "start /wait" at the front of the line you want to wait for. Do start /? in your NT/XP command prompt for more info.

  • On line three of the button code, you are copying the exe file to the FTP site you specify. If your ftp account has an @ sign in it, you need to change that into a %40. The syntax for the ftp site is:

ftp://uid:password@domain.com//path/to/target

  • When you execute, make sure your active path is what you're expecting to zip. Notice the "breadcrumbs" path on top of the view to the right of the tree in dual horizontal, and how it changes when you select in the tree as compared to when you select on the right.

Hope this is helpful to someone.

Cheers.

A couple more tweaks for tuning:

To delete the zip file from the temp directory before the ftp command add this line:

Delete SECURE FORCE QUIET c:\temp\RC{date|yyMMdd}.zip

To move the file to the FTP site, as opposed to copying which leaves the file on your drive, add the MOVE directive after the Copy command:

Copy MOVE c:...exe TO ftp://...

Hi Rick,

I saw your post on the other thread about 4:00 AM my time ( -6 GMT ) .
I half got it when I saw sync:

Be happy tonight.
We both got a bloody nose, but learned a great lesson.

Stop worrying and have some Sake !

I'll post my version tomorrow.

                                 Tsunami

P.S. Thankyou Dopus team for you're heroic rescue !

I'll be interested to see your version, Tsunami.

Regarding zips, I started experimenting with the open source archiver 7-zip, which is freeware (actually donationware) and seems pretty good. I'll try its command line version 7z.exe (gui version also included w/ the download) with long filenames and the like. We'll see how that comes out.

Cheers

Hi Rick,

Here are my first working versions.
I'm still using the two button method I made for zips when this thread started.

Right Mouse Button:
This allows me to have a separate date named zip folder for any Directory I wish.

[DOpus.ButtonInfo]
Name=Create Zip
Icon=84,9999999
Flags=2,0,0
Color=0,a0a0a0
Tooltip=Create Zip
Func1=CreateFolder ZIP NAME={date|yyyy-MM-dd}.zip

Left Mouse Button:
This allows me to add files to today's Current Directory's zip folder.

[DOpus.ButtonInfo]
Name=Copy
Icon=84,9999999
Flags=2,0,0
Color=0,a0a0a0
Tooltip=Copy to Zip
Func1=Copy TO .{date|yyyy-MM-dd}.zip

Middle Mouse Button:
I have two versions of this .
The first attempts to use Dopus functions, but does not append a DirName to the encrypted file. The second is a version I wrote using Take Command. It does append a DirName to the encrypted file.

Version Native Dopus

[DOpus.ButtonInfo]
Name=Encrypt
Icon=84,9999999
Flags=2,0,0
Color=0,a0a0a0
Tooltip=Encrypt
Func1=cd {sourcepath}
Func2=sync:C:!SystemUtilities\ChilkatZipSE.exe -encrypt 128 -password somepass {date|yyyy-MM-dd}.zip
Func3=Rename {date|yyyy-MM-dd}.exe To {date|yyyy-MM-dd}{time|HH-mm-ss}.exe
Func4=Go Openindest ftpsite=www.mysite.net
Func5=Copy {date|yyyy-MM-dd}
{time|HH-mm-ss}.exe TO ftp://user:pass@mysite.net

Version Take Command

[DOpus.ButtonInfo]
Name=Encrypt
Icon=84,9999999
Flags=2,0,1
Color=0,a0a0a0
Tooltip=Encrypt and FTP
Func1=runmode hide
Func2=call C:!SystemUtilities\Encrypt.btm {sourcepath} {date|yyyy-MM-dd} {time|HH-mm-ss}

==================
Encrypt.btm

@echo off
CDD %1
path "C:\DopusPath\DirectoryOpus"
C:!SystemUtilities\ChilkatZipSE.exe -encrypt 128 -password somepass %2.zip
Set pathway=%@INSTR[4, %1]
Set length=%@LEN[%pathway]
Set length=%@EVAL[%length - 2]
Set pathway=%@INSTR[0,%length,%pathway]
IF %length GT 0 Set pathway=%@REPLACE[ ,_,%pathway]
IF %length GT 0 Set pathway=%@REPLACE[,-,%pathway]
Rename /Q %2.exe %2.%pathway.%3.exe
dopusrt.exe /CMD Go Openindest ftpsite=www.mysite.net
dopusrt.exe /CMD Copy %2.%pathway.%3.exe TO ftp://user:pass@mysite.net

Thanks Dopus Team ! Thanks Rick!
Tsunami

This version will work much better.

===========================
Encrypt.btm

@echo off
CDD %1
path "C:\DopusPath\DirectoryOpus"
C:!SystemUtilities\ChilkatZipSE.exe -encrypt 128 -password somepass %2.zip
Set bkslash=%@index[%1,]
Set pathway=%@INSTR[%@EVAL[%bkslash - 2], %1]
Set length=%@LEN[%pathway]
IF %length != 3 (
IF %bkslash == 2 Set length=%@EVAL[%length - 1]
IF %bkslash == 3 Set length=%@EVAL[%length - 2]
Set pathway=%@INSTR[0,%length,%pathway]
)
IF %length GT 3 Set pathway=%@REPLACE[ ,_,%pathway]
Set pathway=%@REPLACE[,-,%pathway]
Set pathway=%@REPLACE[:,-,%pathway]
Rename /Q %2.exe %2.%pathway.%3.exe
dopusrt.exe /CMD Go Openindest ftpsite=www.mysite.net

==============================

I've found it's just as easy or easier to drag and drop the resultant file, so I eliminated the copy line.

I'd like to try to use regular expressions as rename tools for the Native Dopus version.
I've used them in PHP, but not Dopus.
I'll see what I can do.

                             Tsunami

Hi Tsunami - neat script, but what's it written in? Looks like some sort of modified batch processor. 4DOS? I've never seen that file extension - btm.

Hi Rick,

Yes that was 4DOS.
It results in easy to read and understand filenames.
I've been trying to find a way of doing this rename without using JPSoft.

I dug into some C++ this weekend using the Freeware Dev-C++ compiler.
I have no previous C or C++ knowledge, but I'm fair at PHP.

I've managed to output the modified {sourcepath} string and can save it to text file using the > redirect.
Does anyone know how to get that string to a variable in MS DOS? I need the string for the middle part of the rename.
Alternatively does anyone know how to add rename ability to my C++ program.

Remember I have just two days experience here:

String1.ccp

#include
#include <stdlib.h>
#include <assert.h>
#include
using namespace std;

main(int argc,char *argv[])
{
string input_string;
int marker;
assert(argc == 2);
input_string = argv[1];
int len = input_string.size();
if ( len > 3 )
{
input_string = input_string.erase(len - 1, 1);
}
marker = input_string.find(":");
if ( marker != string::npos )
{
input_string = input_string.replace( marker, 1, "-" );
}
marker = input_string.find("\");
while ( marker != string::npos )
{
input_string = input_string.replace( marker, 1, "-" );
marker = input_string.find("\");
}
marker = input_string.find(" ");
while ( marker != string::npos )
{
input_string = input_string.replace( marker, 1, "_" );
marker = input_string.find(" ");
}
cout << input_string;
cout << endl;
return 0;
}

==================================
One simply runs String1.exe %1
%1 is {sourcepath} as seen by the batch file.
See previous post in this thread for more info.

                           Tsunami

Does anyone know how to get that string to a variable in MS DOS?

I haven't really been following this thread so I don't know where you're going with all this, but to answer your question here is one way to set a variable to a known string value in CMD scripts:

for /f "delims=*" %%a in ("Hello There") do set X=%%a

where VAR X is set to the string value of Hello There

We might not want to wander too far off the DOpus path with all this in here, after all external batch files and C languages are not really relevant to DOpus (at least to most folks).

John