3/20/2019                                              Wing FTP Software - Forum - looking for Lua assistance
Home           Download           Purchase       Support          Forum
      Board index ‹ Wing FTP Server ‹ Lua scripts
                                                                                                         FAQ    Register      Search      Login
looking for Lua assistance
Post a                                                                                                                     6 posts • Page 1 of 1
reply
                Search this topic…            Search
   looking for Lua assistance                                                                                     businessclient
     by businessclient » W e d O ct 14, 2015 8:02 pm                                                                            4
   I am using the send mail feature for OnFileUploaded and it works great but I've been asked                                   Tue O ct 13,
   "can this email notice only go to the people that are members of the group belonging to the
                                                                                                                  2015 6:56 pm
   file share that the document was uploaded into?".
   All I'm doing today is super simple but global as it sends to a distribution mailbox with an
   email body of; %Name from %IP uploaded %PathName using %ClientVersion
   I'm hoping someone has had this need before me and I'm guessing they would have used Lua
   to tackle this need.
   Can anyone help me with some newbie Lua example code?
   Thanks, in advance.
   Re: looking for Lua assistance                                                                                 FTP
                                                                                                                  Site Adm in
     by FTP » Thu O ct 15, 2015 3:42 am
                                                                                                                                1627
   OK, you can define the user email under "User -> Notes", and then use the following lua
   script:                                                                                                                      Tue Se p 29,
                                                                                                                  2009 6:09 am
    CODE: SELECT ALL
    local user = c_GetUser("%Domain","%Name")
    local user_email = user.note_email
    if user_email ~= nil and user_email ~= "" then
         c_SendMail(user_email,"a file has been uploaded","%Name uploaded into
    %PathName","","SMTP_CONFIG")
    end
   You can add the above Lua script into the event "OnFileUploaded -> Lua script".
   And, "SMTP_CONFIG" is the smtp configuration name at the "Servers -> Settings -> SMTP
   Manager".
   Re: looking for Lua assistance                                                                                 businessclient
     by businessclient » Thu O ct 22, 2015 12:38 am
https://bbs.wftpserver.com/viewtopic.php?f=6&t=3183                                                                                            1/3
3/20/2019                                             Wing FTP Software - Forum - looking for Lua assistance
   I've been working with the system and think it's great but I ran into a user request I'm                                  4
   having trouble filling.
                                                                                                                             Tue O ct 13,
                                                                                                               2015 6:56 pm
   I have been working a little with Lua, (never used it before), and writing a script in shell and
   passing it variable valuables through the Execute Program tab that is triggered under HTTP
   OnFileUploaded.
   My issue is the Lua script offered here and anything called from shell work fine but can only
   notify a single person or list of people if the email is sent to a distribution list on the email
   server.
   What I can't find are groups and members variables. What I'm getting asked to do is this;
   there are outside clients uploading into wftpserver and a notice is sent to internal staff, this
   is good. But, the internal staff will upload a file into the folder assigned to the outside
   clients and they would like an email notice sent to that client to let them know it is ready for
   download.
   The outside clients are all in a common group, i.e. group ABC has members bob, jane and
   ted sharing a directory /home/abc and group XYZ has members mary, harry, and phil
   sharing a directory /home/xyz
   When the internal staff uploads a file into /home/abc they want an email sent to bob, jane,
   and ted to let them know to come download the file. If the staff uploads a file into
   /home/xyz then they want a notice sent to mary, harry and phil to come download it.
   I don't see variables to know what groups people are in for using Lua or shell scripts or perl.
   Is this possible to do with Lua or an external script?
   Thanks for any help.
   Re: looking for Lua assistance                                                                              FTP
                                                                                                               Site Adm in
     by FTP » Fri O ct 23, 2015 6:23 am
                                                                                                                             1627
   OK, in WingFTP, the group is not based on the folder name, so maybe you take the following
   methods:                                                                                                                  Tue Se p 29,
                                                                                                               2009 6:09 am
   1. You can use some hard-coded Lua script, specify the group members for each folder.
   2. When a user uploads a file, then you can know the groups this user belongs to, then you
   can send emails to the other members of those groups.
   Re: looking for Lua assistance                                                                              businessclient
     by businessclient » Fri O ct 23, 2015 4:02 pm                                                                           4
   ok, Thanks for the help.
                                                                                                                             Tue O ct 13,
                                                                                                               2015 6:56 pm
   I'm wondering... I have had my best luck using shell script or perl and passing vars using the
   Execute Program feature but that's really because I have never used Lua and I'm getting
   carried away with a custom email message that would be tough to type inside the little Lua
   dev window. :-)
   I can easily pass the directory it has been uploaded into. I have my users in common groups
   and those common groups have common shared directories. Is there a group variable I can
https://bbs.wftpserver.com/viewtopic.php?f=6&t=3183                                                                                         2/3
3/20/2019                                                 Wing FTP Software - Forum - looking for Lua assistance
   pass out to an external script? I didn't see one in the manual. If not, can i create one using
   Lua to pass to an external script?
   Thanks again.
   Re: looking for Lua assistance                                                                                          FTP
                                                                                                                           Site Adm in
     by FTP » W e d O ct 28, 2015 4:00 am
                                                                                                                                         1627
   OK, though I am not very clear about what you need, but for your requirements:
                                                                                                                                         Tue Se p 29,
   1. You can get all the groups with such script:                                                                         2009 6:09 am
    CODE: SELECT ALL
    local allgroups = ""
    local user = c_GetUser("%Domain","%Name")
    if (user.usergroups ~= nil) then
      for _,v in pairs(user.usergroups) do
        allgroups = allgroups..","..v.groupname
      end
    end
   2. You can execute an external program via such script:
    CODE: SELECT ALL
    os.execute("/storage/bin/OnFileUploaded                  --Domain       %Domain      --Name      %Name         --
    PathName \"%PathName\" --IP %IP")
                          Display posts from previous: All posts            Sort by Post time            Ascending            Go
Post a                                                                                                                             6 posts • Page 1 of 1
reply
   Return to Lua scripts                                                                            Jump to:            Lua scripts                     Go
WHO IS ONLINE
Users browsing this forum: No registered users and 1 guest
                                                               Switch to m obile style
      Board index                                                                   The team • Delete all board cookies • All times are UTC
                                             Powe re d by phpBB © 2000, 2002, 2005, 2007 phpBB Group
https://bbs.wftpserver.com/viewtopic.php?f=6&t=3183                                                                                                      3/3