Archive

Posts Tagged ‘perl’

win-get apt-get for windows

April 9th, 2009 No comments

win-get apt-get for windows

One thing I love of Debian is apt-get command, so why not have not the same, ok not the same but something similar run on Windows?, I search some projects on sf.net but don’t work or are not updated, so I made my own project and works fine:

You can download executable file and source file (perl script) on:
http://win-get.ayalasoft.com

Categories: develop, network, projects, web, windows Tags: ,

FTP for Developers

January 29th, 2009 2 comments

FTP for Developers

This examples upload a simple text file for a better implementations read the API or documentation for each language or command

Curl:

curl -T filename -u username:password ftp://hostname/filename

Perl:

use Net::FTP;
$hostname = "localhost";
$username = "user";
$password = "pass";
$filename = "file.txt";
$ftp = Net::FTP->new($hostname);
$ftp->login($username,$password);
$ftp->put($filename);
$ftp->quit;

To handle errors use “or die $@” (“$ftp>message” only if login success)

PHP:

<?php
$hostname = "localhost";
$username = "user";
$password = "pass";
$filename = "file.txt";
$conn = ftp_connect($hostname); 
ftp_login($conn, $username, $password);
ftp_put($conn,$filename,$filename,FTP_ASCII);
ftp_close($conn);
?>

To handle erros you can use “if(!function)”

Python:

import ftplib
hostname = "localhost"
username = "user"
password = "pass"
filename = "file.txt"
ftp = ftplib.FTP(hostname)
ftp.login(username, password) 
ftp.storlines("STOR " + filename, open(filename))
ftp.quit()

To handle errors use “try” and “except” and “else”

Ruby:

require 'net/ftp'
host = 'localhost'
user = 'user'
pass = 'pass'
file = 'file.txt'
ftp = Net::FTP.new(hostname)
ftp.login(username,password)
ftp.puttextfile(filename)
ftp.close

To handle errors use “begin”, “rescue”, “else”, “ensure” and “end”.

Win32 batch:

ftp -s:settings.txt hostname

settings.txt:

username
password
put filename
bye

To handle errors use “if not %errorlevel%==0 goto :error”

Send Fake Mail

December 5th, 2008 6 comments

Send Fake Mail

Remember is very posible the mail was arrived on Junk Box.

#!/usr/bin/perl
# Script: fakemail.pl, Version 1.0  [2008-12-04]
# Author: Albertux (Alberto Isaac Ayala Esquivias)
# Web Author: http://Albertux.AyalaSoft.com
# FeedBack:
# Description: Send fake mail.
# Licence: GPLv3
 
use strict;
use warnings;
 
# Chouse the host to connect on port 25
my $host='localhost'; 
 
# The vars
my @raw_data=;
my ($mail1, $mail2, $name1, $name2, $subject, $data );
 
print "Fake Mail: ";
chomp($mail1 = &lt;&gt;);
print "Destiny Mail: ";
chomp($mail2 = &lt;&gt;);
print "Fake Name: ";
chomp($name1 = &lt;&gt;);
print "Destiny Name: ";
chomp($name2 = &lt;&gt;);
print "Subject: ";
chomp($subject = &lt;&gt;);
print "Data: ";
chomp($data = &lt;&gt;);
 
foreach(@raw_data) {
	$_ =~ s/MAIL1/$mail1/g;
	$_ =~ s/MAIL2/$mail2/g;
	$_ =~ s/NAME1/$name1/g;
	$_ =~ s/NAME2/$name2/g;
	$_ =~ s/SUBJECT/$subject/g;
	$_ =~ s/DATA/$data/g;
	$_ =~ s/\\n/\n/g;
}
 
print "mail send.\n";
 
open(STDOUT, "| telnet ".$host." 25 &gt; /dev/null 2&gt;&amp;1");
foreach (@raw_data) {
	print STDOUT $_;
}
 
1;
 
__DATA__
mail from: MAIL1
rcpt to: MAIL2
data
From: NAME1
To: NAME2
Subject: SUBJECT
DATA
.
quit
Categories: develop, network, security Tags: ,

TODO LIST 2009

December 1st, 2008 1 comment

TODO LIST 2009

Read/Learn/Practice:

Python 2.6 (What’s New)

Perl 5 (Modules, Packages)

PHP (Changes, and news)

COBOL

.NET (C#, LINQ, (ok VB but not much))

Java (Im interested on Mobil Applications)

Haskell

Ruby (Im interested on Rails)

Parrot and Pugs

Gnu/Linux (Services and Bash)

BSD and OpenSolaris

Personal Projects 2009:

BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com)

Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx)

Forming one’s own business

And others ….

Lambda Functions on PHP 5.3.0:

 $lambda = function () { echo "Hello World!\n"; };

Parrot “Hello World” example:

.sub main
      print "Hello World!\n";
.end

COBOL “Hello World” example:

* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
	IDENTIFICATION DIVISION.
	PROGRAM-ID.    hello.
	ENVIRONMENT DIVISION.
	DATA DIVISION.
 
	PROCEDURE DIVISION.
		DISPLAY "Hello ," WITH NO ADVANCING
		DISPLAY "World!"
		STOP RUN.

Haskell “Hello World” example:

putStrLn "Hello World!"

SQL File to PHP5 Classes (sql2class)

November 25th, 2008 No comments

SQL File to PHP5 Classes (sql2class)

(shell prompt) perl sql2class.pl database.sql > classes.php

Download sql2class-0.2.tar.gz sql2class-0.3.tar.gz

I have little time programming in Perl hope to expand this script to support other languages in the future

With this post I dismissal from 2008 until January 2009.

Categories: database, develop Tags: , ,

Switch to our mobile site