Easy Pass to Secure File Transfer
TM
»User: »Password:   Remember Me? 
Sysax Product Forums / Sysax Multi Server / General Discussion / scripting with variables as arguments
Posted:  25 Sep 2010 05:35
I want to use growl for notifications

I need to end up outputting a line to the command line that looks exactly like this-

growlnotify /t:"SYSAX SERVER" "USER has logged in successfully."

and I am trying to have the USER replaced with the variable supplied from the event. My code looks like this-


# Notify Growl of User Login
if ~SERVER_TRIGGER eq "loginok" begin
    setvar ~args, "/t:\"FTP server\"", ~SERVER_ACCOUNT,"\" has logged in successfully.\"";
    ftprunprogram "c:\\WINDOWS\\system32\\growlnotify.com", ~args;
end

I am having real trouble with the double quote situation. Fortunately I realized that \ was the escape character, which I didn't notice in the documentation anywhere. Using \ solved some problems but I can't get the the ~SERVER_ACCOUNT to pass the actual user along with this formatting. It's a syntactical nightmare.
Every time the 'ftprunprogram' line sees two sets of quotes it moves to the next argument, but I need to get the ~SERVER_ACCOUNT parsed to the user and output to the command line inside of double quotes somehow.
Posted:  25 Sep 2010 20:34
Figured it out.

Here it is if anyone is interested. needed to use strprint instead of setvar
Works well to integrate growl


print "Starting to execute server script ...";

# Trim absolute filename to the homefolder- THIS WILL VARY DEPENDING ON YOUR FILE STRUCTURE
    if ~SERVER_ABSFILENAME ne "" begin
    setvar ~FILE, ~SERVER_ABSFILENAME;
    strslice ~FILE, left, 79, 0;
    end

# Notify Growl of User Login
    if ~SERVER_TRIGGER eq "loginok" begin
    strprint ~args, "/t:\"FTP SERVER\" \"", ~SERVER_ACCOUNT, " has logged in successfully.\"";
    end

# Notify Growl of Failed Login
    if ~SERVER_TRIGGER eq "loginerror" begin
    strprint ~args, "/t:\"FTP SERVER\" \"The IP address ", ~SERVER_IPADDRESS, " attempted to log in but failed.\"";
    end

# Notify Growl of File Download
    if ~SERVER_TRIGGER eq "download" begin
    strprint ~args, "/t:\"FTP SERVER\" \"", ~SERVER_ACCOUNT, " has downloaded the file ", ~FILE, "\"";
    end
   
# Notify Growl of Uploaded File
    if ~SERVER_TRIGGER eq "upload" begin
    strprint ~args, "/t:\"FTP SERVER\" \"", ~SERVER_ACCOUNT, " has uploaded the file ", ~FILE, "\"";
    end
   
# Notify Growl of Renamed File
    if ~SERVER_TRIGGER eq "rename" begin
    strprint ~args, "/t:\"FTP SERVER\" \"", ~SERVER_ACCOUNT, " has renamed the file ", ~FILE, "\"";
    end
   
# Notify Growl of Deleted File
    if ~SERVER_TRIGGER eq "delete" begin
    strprint ~args, "/t:\"FTP SERVER\" \"", ~SERVER_ACCOUNT, " has deleted the file ", ~FILE, "\"";
    end

# print the args to the log file
    print "the arguments are: ", ~args;

# run growlnotify with args
    ftprunprogram "c:\\WINDOWS\\system32\\growlnotify.com", ~args;
   
print "Script Completed.";
 

Copyright © 2008 Codeorigin, LLC - All Rights Reserved.
XML RSS 2.0 XML Atom 1.0