Gossamer Forum
Home : General : Perl Programming :

Probably a dumb question....

Quote Reply
Probably a dumb question....
Ok, how would you execute a Telnet command via a script?

e.g

gzip -c filename.html > test.tar.gz

I've had a look at CGI-Telnet ( a program i found at HotScripts), but I can't find how they access the server from it.

Any help will be much appreciated!

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Probably a dumb question.... In reply to
Don't worry, I wokred it out :)

Man it was easy! Surprised I didn't think of it earlier Wink

I used;

$server = `gzip -c test.html > test.tar.gz`;
print "Content-type: text/html \n\n";
print "$server";

Thanks though.

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Probably a dumb question... In reply to
Why are you trying to print the binary file?
Quote Reply
Re: Probably a dumb question.... In reply to
I'm not sure Wink

Just seemed to work, so I left it :)

Is there a better way to do it?

Andy


webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Probably a dumb question.... In reply to
All you need is:

Code:
`gzip -c test.html > test.tar.gz`;
Obviously you can print the output if you do it the way you have done above but simply to gzip the file you can use the above code.


Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Probably a dumb question.... In reply to
Oh, wicked! Thanks. Even more simple than I had though Wink

Simple is good for me...lol

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Probably a dumb question.... In reply to
Just another point in regards to your original code:

When you are printing a variable you don't need to surround it with quotes like:

print "$server";

Just use

print $server;

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Probably a dumb question.... In reply to
Hi. Just another stupid question, didn't think there was much point in starting a new thread. How would I gzip many files into one .tar.gz?

I tried;

gzip -c file1.html file2.html file3.html > test.tar.gz

but that didn't work. I also tried;

gzip -c "file1.html file2.html file3.html" > test.tar.gz

but that didn't wrok either.

Any help please?

Thanks

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Probably a dumb question.... In reply to
You do know that JerrySu posted codes for creating tar.gz files of multiple files in the Links 2.0 Discussion Forum about a year and a half ago, don't you???

Anyway...here are similar codes that he posted....

Code:

my $db_data_path = "/absolute/path/to/data";
my $db_backup_path = "/absolute/path/to/backup";
if (open (TAR, "/usr/local/bin/tar cf $db_backup_path/temp.tar $db_data_path/
* |")) {;
close TAR;
open (GZ, "/usr/local/bin/gzip -c $db_backup_path/temp.tar > $db_backup_path/
$date.tar.gz |") or &cgierr($!);
print qq~\tBacked up files in the $db_data_path directory... \n~;
close GZ;
unlink("$db_backup_path/temp.tar") or &cgierr($!);
}


Of course, you may have to change the path to GZIP and TAR.

Regards,

Eliot Lee
Quote Reply
Re: Probably a dumb question.... In reply to
If your tar supports it:

tar czf /path/to/file.tar.gz file1.html file2.html ...

The 'z' means to gzip it. If not, you need to do:

tar czf /path/to/file.tar file1.html file2.html ...
gzip /path/to/file.tar

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Probably a dumb question.... In reply to
Brilliant :)

Thanks! It works.....Smile

Andy

webmaster@ace-installer.com
http://www.ace-installer.com