Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

edit locally, run on the server

 
Post new topic   Reply to topic    Community Forum Index -> Tips
View previous topic :: View next topic  
Author Message
OnlyTextPad



Joined: 20 May 2006
Posts: 41
Location: Helsinki

PostPosted: Thu Sep 06, 2007 7:21 am    Post subject: edit locally, run on the server Reply with quote

This is constrained implementation of an broader idea. First the idea consisting of the following:
- 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 = <FILE> ;
   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

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Tips All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB