- to be able to work locally (e.g. on a Windows PC with TextPad )on an entire project of any type of source files - e.g. Perl, Java , C++ , etc.
- to be able to check for syntax errors with one keyboard shortcut on the server environment - e.g. one shortcut would upload the entire project on the server and call the syntax checking command, as well as get the possible errors or success messages and bring them back to the TextPad's environment for jump to error line
- to be able to run the whole project (with any possible parameters ) with receiving any possible ok and / or error messages
So far my implementation is combariably small , but it works using winscp as the file transfer and server side command execution tool.
Any thoughts would be appreciated ... Code:
#=============================PERL_TOOL_FOR_CALLING_WINSC_START
package upDown ;
use warnings ;
use strict ;
#Docs at the end ..
sub main
{
my $self = shift ;
my $cmd ="winscp /console userName\@server.com /script=winscp_scripit.pl" ;
`$cmd` ;
for ( "./ok.log" , "./error.log" )
{ dumpFile($self , $_ );
}
} #of main
sub dumpFile
{
my $self = shift ;
my $file = shift ;
open (FILE,$file);
my @rows =
foreach my $line (@rows) { print "$line" ; }
close (FILE);
}
main(); #action!!!
1;
__END__
#Purpose:
# Upload the code file , run the command on the server
# Download the command results , echo them from this script
#to be captured by the TextPad for jumping to the error row
#PREREQUISITES Windows + winscp + configured session
#Textpad + configured the following option Ctrl + 7 , perl $FileName
#Capture output , Regex: ^.+at (.+) line ([0-9]+)[.,]? , $FileDir , $
#TODO :
# - parametrize the code file name
# - how about a whole file folder project - e.g. uploading recursively ....
# - parametrize session name
#=============================PERL_TOOL_FOR_CALLING_WINSC_END
#=============================WINSCP_SCRIPT_START
#winscp_scripit.pl
#Note: the *. pl fileext is just for the Perl syntax highlighting ... you should have winscp in your path
#This file should be in the same dir as the Perl tool
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Enable overwrite confirmations that conflict with the previous
option confirm on
# Change remote directory
cd /home8/24/userName/var
# Force ASCII mode transfer
option transfer ASCII
#upload the file
put C:\temp\temp\sendPerlMail.pl
call perl sendPerlMail.pl 1>ok.log 2>error.log
# Download file to the local directory d:\
#get both the logs \ to the end of the folders!!!
get ok.log C:\temp\temp\
get error.log C:\temp\temp\
#delete the logs
call rm -f error.log
call rm -f ok.log
# Disconnect
close
# Exit WinSCP
exit
#=============================WINSCP_SCRIPT_END
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!