no message

main
이범준 4 months ago
parent 603512e62c
commit 3e944c8e4d

@ -2,14 +2,31 @@
#!/usr/bin/expect -f
if [ $# -lt 1]
then
echo "I Hope your input. [TARGET_FILE]"
echo "I Hope your input. [FILE_NAME]"
exit
fi
TARGET_FILE=$1
SRC_DIR=$2
LAYOVER_DIR=$3
DEST_DIR=$4
DEST_NAME=$5
if [ $# -lt 2]
then
echo "I Hope your input. [WAS_DIR]"
exit
fi
if [ $# -lt 3]
then
echo "I Hope your input. [WEB_DIR]"
exit
fi
if [ $# -lt 4]
then
echo "I Hope your input. [FILE_ID]"
exit
fi
FILE_NAME=$1
WAS_DIR=$2
WEB_DIR=$3
FILE_ID=$4
java -jar /gpta/source-app/cfs/relay_jar/customSender.jar $TARGET_FILE $SRC_DIR $LAYOVER_DIR $DEST_DIR $DEST_NAME &
java -jar /gpta/source-app/cfs/relay_jar/customSender.jar $FILE_NAME $WAS_DIR $WEB_DIR $FILE_ID &

@ -1,6 +1,11 @@
import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.log4j.Logger;
@ -8,49 +13,95 @@ public class CustomSender {
public static final Logger logger = Logger.getLogger(CustomSender.class);
private static String[] g_strDB = new String[4];
private static String ofileName = "";
private static String wasWorkDir = "";
private static String webWorkDir = "";
private static String sujibWorkDir = "";
private static String finalDest = "";
private static String finalDestWorkDir = "";
private static String fileId = "";
public static void main(String[] args) {
String fileName = args[0];
if(args.length != 4) {
System.err.println("총 4개의 args를 입력하지 않았습니다.");
System.exit(0);
return;
}
ofileName = args[0];
wasWorkDir = args[1];
webWorkDir = args[2];
sujibWorkDir = args[3];
finalDestWorkDir = args[4];
finalDest = args[5];
fileId = args[3];
CustomSender self = new CustomSender();
// 프로퍼티 파일 위치
String propFile = "/gpta/source-app/cfs/relay_jar/config.properties";
// 프로퍼티 파일 로딩
try {
// 프로퍼티 객체 생성
Properties props = new Properties();
// 프로퍼티 파일 스트림에 담기
FileInputStream fis = new FileInputStream(propFile);
props.load(new java.io.BufferedInputStream(fis));
File file = new File(wasWorkDir + "/" + fileName);
int ftpResult = self.setFtpData(file, fileName);
// 항목 읽기
g_strDB[0] = props.getProperty("db_driver");
g_strDB[1] = props.getProperty("db_connect");
g_strDB[2] = props.getProperty("db_id");
g_strDB[3] = props.getProperty("db_pw");
if(ftpResult != -1) {
self.deliveryReq(
webWorkDir+"/"+file.getName(),
sujibWorkDir+"/"+file.getName(),
finalDestWorkDir+"/"+file.getName(),
finalDest
);
} catch (Exception e) {
e.printStackTrace();
return;
}
CustomSender self = new CustomSender();
try {
self.run();
} catch (Exception e) {
e.printStackTrace();
}
}
private void deliveryReq(String srcPath, String layoverPath, String destPath, String destName) {
FTPUtil ssh = new FTPUtil();
ssh.initExec("175.193.201.56", "tmax","tmax1234");
ssh.run("curl --insecure -X GET "
+ "d \"srcPath="+srcPath+"&layoverPath="+layoverPath+"&destPath="+destPath+"&from=web4&to="+destName+"\" "
+ "http://192.168.201.120/deliveryReq.do"
);
private void run() throws Exception {
File file = new File(wasWorkDir + "/" + ofileName);
int ftpResult = this.setFtpData(file, ofileName);
if(ftpResult == -1) {
return;
}
Connection conn = null;
PreparedStatement ps = null;
try {
conn = getOrclConn();
String sql = "UPDATE TB_CUSTOM_COMMAND "
+ " SET STAT_CD = '1' "
+ " WHERE FILE_ID = '"+fileId+"' ";
ps = conn.prepareStatement(sql);
ps.executeUpdate();
conn.commit();
ssh.disconnectSession();
}catch(Exception e){
e.printStackTrace();
}finally{
if(ps != null) {
ps.close();
}
conn.close();
}
}
private int setFtpData(File file, String fileNm) {
FTPUtil sftp = new FTPUtil();
@ -79,4 +130,9 @@ public class CustomSender {
return nReturn;
}
private Connection getOrclConn( ) throws Exception{
Class.forName(g_strDB[0]);
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
}
}

@ -213,16 +213,6 @@ public class FTPUtil {
channelSftp.quit();
session.disconnect();
}
public void disconnectSession() {
session.disconnect();
}
public void run(String string) {
channelExec.setCommand(string);
try {
channelExec.connect();
} catch (JSchException e) {
e.printStackTrace();
}
channelExec.disconnect();
}
}

Loading…
Cancel
Save