-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfcx.py
57 lines (46 loc) · 2.42 KB
/
sfcx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import paramiko
def sfcx(account, begin_date, end_date=''):
# 开启SSH通道
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='10.0.134.110', port=22, username='hisusr', password='hisusr')
# ssh.connect(hostname='192.168.57.128', port=22, username='db2inst1', password='db2inst1')
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/cx.sh {account} {begin_date} {end_date}'
.format(account=account, begin_date=begin_date, end_date=end_date))
def open_date_query(id_no='', org_no='', account='', name=''):
# 开启SSH通道
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.connect(hostname='10.0.134.110', port=22, username='hisusr', password='hisusr')
ssh.connect(hostname='192.168.57.128', port=22, username='db2inst1', password='db2inst1')
if id_no:
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/kh_zj_ds.sh {id_no}'
.format(id_no=id_no))
if org_no:
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/kh_zj_dg.sh {org_no}'
.format(org_no=org_no))
if account:
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/kh_zh.sh {account}'
.format(account=account))
if name:
transport = paramiko.Transport(("10.0.134.110", 22))
transport.connect(username='hisusr', password='hisusr')
sftp = paramiko.SFTPClient.from_transport(transport)
with open('c:/sfcx/dg_name.txt', 'w', encoding='gbk') as f:
f.write(name)
sftp.put('c:/sfcx/dg_name.txt', '/datatmp/sjm/YX_SFCX/dg_name.txt')
sftp.close()
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/kh_mc_dg.sh')
def pos_query(account, date, amt):
# 开启SSH通道
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='10.0.134.110', port=22, username='hisusr', password='hisusr')
stdin, stdout, stderr = ssh.exec_command(
'. /dbhome/hisusr/.profile;sh /datatmp/sjm/YX_SFCX/pos.sh {account} {date} {amt}'
.format(account=account, date=date, amt=amt))