Quantcast
Channel: THWACK: All Content - Serv-U FTP Server & MFT Server
Viewing all articles
Browse latest Browse all 659

Unzip Files After They Are Uploaded to Serv-U For Linux

$
0
0

Executable Path in Serv-U KB Article #2160 was invalid in my CentOS, the following is worked:

 

1.If you want to unzip a File after uploaded event on the server or domain level,

   navigate to [Server/Domain Details] > [Events] in the Management Console.

   If you want to create this event on the group or user level, select the appropriate user or group under Users/Groups,

   click [Edit], and then click [Events].

2.Click [Add].

3.Select [File Uploaded] from the [Event Type] list.

4.Provide an event name [autounzip] and an optional description.

5.Under [Event Actions], select [Execute Command] from the [Action] list.

6.In [Executable Path], browse to the file that contains the command you want to execute.

   Serv-U's default PATH=/sbin:/usr/sbin:/bin:/usr/bin

   Serv-U's default dir=/bin

   So, specify it to [/bin/sh]

7.Specify the following Command Line Parameters.

   "$LocalPathName" is full name of Uploaded file,

   autounzip.sh is located on Serv-U path,

   So, specify it to [/usr/local/Serv-U/autounzip.sh $LocalPathName]

8.Specify the number of seconds to wait after starting the executable path in the [Completion Wait Time] field.

   Note: Configuring a value for Completion Wait Time will block Serv-U while it waits.

   So, specify it to 0

9.Click Save.

 

#!/bin/bash

# Program: autounzip.sh

parm1=$1

parm2=${parm1%/*}

parm3=${parm2}/autounzip.log

parm4=${parm1##/*.}

if [ "${parm4}" == "zip" ] || [ "${parm4}" == "ZIP" ]; then

# -o overwrite files without prompting

# -d extract files into exdir

#  ${parm1} uploaded file to be extracted

#  ${parm2} the same path of uploaded file

#  ${parm3} unzip output file

#  ${parm4} filename extension, trigger only .zip

unzip -o ${parm1} -d ${parm2} >  ${parm3}

fi

# exit the script

exit


Viewing all articles
Browse latest Browse all 659

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>