Jump to content

Praying to the code Gods


Uncle Toxie

Recommended Posts

I'm still not sure how this keeps happening to me. My boss (the coder) comes to me (the NOT coder) and asks me to write a program/script to get a few things done. The fact that I am not a programer seems to lost on folks.

Anywho, this is what he wants done, if anyone knows how to do this or can point me in a direction so that I can try it, I will praise your name, in this thread.

We want to have a folder where we can drop some files, have them encrypted with GPG, FTP'ed to a set location, create a log of the transaction, and then delete the files in that folder. It would seem that he wants the script (or whatever) to scan the folder all the time so as soon as files are dropped in the folder everything kicks in.

It doesn't matter what the language is, he just wants it to work. The only experiance I have ever had was a year or so ago in VB6 so I am at a loss.

Thanks for any input, I'm headed back to Google.........

Link to comment
Share on other sites

Not helpful to you in the sense of solving the dilema in the fashion of creating a program...but you should tell him bluntly, straight, and fairly that you aren't a coder and don't know how to do it. There's nothing he can say/do thereafter.

Link to comment
Share on other sites

Now im no great coder... but the easiest way to do it i should think... from what you just said:

Linux box, samba for windows file shareing.. (so you can allow users to place files into there)

Then just have a cron job running every say 30 seconds.

(maybe checking if the files are still being written too first and deferring the task for another 30 seconds if they are.. so you dont encrypt half a file ;))

Which just, locks the folder. (chmod command) uses the commandline version of GPG to encrypt the folder... use the ftp command to upload it... then the rm command to remove the files and encrypted file you just made, you could even pipe all the information chucked out by those commands into a log file if you wanted.

Anyone else got any ideas?

Link to comment
Share on other sites

I'd use perl

for ftp its:

Net::FTP;

my $ftp = Net::FTP->new($host, Debug => 0)

      or die "Cannot connect to $host: $@";



    $ftp->login("$user","$pass")

      or die "Cannot login ", $ftp->message;



        $ftp->ascii;

    $ftp->cwd("$directory")

      or die "Cannot change working directory ", $ftp->message;



   foreach my $file ($ftp->ls($pattern))

        {

           my $doThis=`cd $store_here`;

          $ftp->get($file) or warn $ftp->message;

        #crappy module cannot store into a sep dir or do mget

            my $doThis=`mv -u $file $store_here`;

        }

    $ftp->quit;

ok above is shit. Please for the love of god rewrite it :)

and the gpg stuff:

 use GnuPG qw( :algo );



    my $gpg = new GnuPG();



    $gpg->encrypt(  plaintext   => "file.txt",  output      => "file.gpg",

                    armor       => 1,            sign   => 1,

                    passphrase  => $secret );



    $gpg->decrypt( ciphertext   => "file.gpg",  output      => "file.txt" );



    $gpg->clearsign( plaintext => "file.txt", output => "file.txt.asc",

                     passphrase => $secret,   armor => 1,

                    );



    $gpg->verify( signature => "file.txt.asc", file => "file.txt" );



    $gpg->gen_key( name => "Joe Blow",      comment => "My GnuPG key",

                   passphrase => $secret,

                    );

to create a log just do a redirect of the output to a text file,

linkage:

GnuPG

net::ftp

I havnt used gnuPG but i think thunderbird uses it...or maybe im thinking of opengpg ...meh

Link to comment
Share on other sites

There's nothing he can say/do thereafter.

"Your fired, get your shit and get out." Guess that kinda blows a hole in that theory eh leetabix? :)

I was able to find out that we have a pearl script that is doing almost everything that he wants done. The only difference is this script looks for two very specific files and we need it to look for any file.

So, since I am unable to just say something and convey my meaning here is what I have that needs changed:

my $WorkDir            = '/home/samba/';

my $ArchiveDir        = $WorkDir . 'archive/';

my $SourceDir        = '/home/bostax/';

my @Files            = ( 'tax_proptrust.csv', 'tax_propparcel.csv' );

I am trying to find a way to have the my @Files portion look for a wildcard of some kind that will apply this script to any file in the specified directory.

Again, thanks for all the help with this one![/code]

Link to comment
Share on other sites

There's nothing he can say/do thereafter.

"Your fired, get your shit and get out." Guess that kinda blows a hole in that theory eh leetabix? :)

Thats when you sue for unfar dismissal. Unless of course you have been hired as a programmer, otherwise he cant actually fire you because you dont have the skills to do something that he wants done.

Link to comment
Share on other sites

There's nothing he can say/do thereafter.

"Your fired, get your shit and get out." Guess that kinda blows a hole in that theory eh leetabix? :)

I was able to find out that we have a pearl script that is doing almost everything that he wants done. The only difference is this script looks for two very specific files and we need it to look for any file.

So, since I am unable to just say something and convey my meaning here is what I have that needs changed:

my $WorkDir            = '/home/samba/';

my $ArchiveDir        = $WorkDir . 'archive/';

my $SourceDir        = '/home/bostax/';

my @Files            = ( 'tax_proptrust.csv', 'tax_propparcel.csv' );

I am trying to find a way to have the my @Files portion look for a wildcard of some kind that will apply this script to any file in the specified directory.

Again, thanks for all the help with this one![/code]

mmm difficult... you try puting a system command (i am assuming unix) in there instead. Somethinglike

my @Files            = ( `ls $SourceDir` );

This *should* (heh heh) put the contents of that dir in an array. But this is bad code-fu..because if u have like 1000+ files that means a lotta memory. It is best to skip the @Files. Then use a loop instead.

Hope this helps dude.

Link to comment
Share on other sites

Thats when you sue for unfar dismissal. Unless of course you have been hired as a programmer' date=' otherwise he cant actually fire you because you dont have the skills to do something that he wants done.[/quote']

Texas is what they call a right to work state, they can fire me because they don't like the shirt that I am wearing. To be fair, I went back to talk to him after work today and he knows as much about Perl as me. He doesn't expect me to write anything, he just hoped that I could find something we could use. I have a habbit of spending days burried in Google and forums and finding a workable solution to our issues.

Bottem line, we need to work on our communication skills in IT department. :D

Thanks for the suggestion wetelectirc, I am going to try that. Memory won't really be an issue, the folder is controled by three people and we know exaclty what will be dumped in there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...