I am starting SAP GUI through subprocess. However, I need it to start in administrator mode. What do I need to change in the code?
path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(3)
SapGuiAuto = win32com.client.GetObject("SAPGUI")
if not type(SapGuiAuto) == win32com.client.CDispatch:
print('return')
application = SapGuiAuto.GetScriptingEngine
connection = application.OpenConnection("ECC QAS", True)
time.sleep(3)
session = connection.Children(0)
try:
session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "300"
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = 'USER' #USUARIO
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = 'PASSWORD' #SENHA
session.findById("wnd[0]/usr/txtRSYST-LANGU").text = 'PT' #IDIOMA
session.findById("wnd[0]").sendVKey(0) #ENTER
except:
print(sys.exc_info()[0])
Related
I am new to netmiko/Python scripting , Using online examples was able to make a script to take configuration backup. The backup is copied to the text file and output is saved.
Currently this backup is done sequentially and it does not connect to all device at once and take the backup. I want to connect to all the devices concurrently.
I understand multithreading or concurrent.futures can solve this issueenter code here but I was not able to do it so far.
Can anyone please suggest, how my existing code can be modified to achieve it. Below is the code.
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException
from paramiko.ssh_exception import SSHException
from netmiko.ssh_exception import AuthenticationException
import getpass
import sys
import time
import os
from datetime import datetime
##getting system date
day=time.strftime('%d')
month=time.strftime('%m')
year=time.strftime('%Y')
today=day+"-"+month+"-"+year
enter code here
##initialising device
device = {
'device_type': 'cisco_ios',
'ip': '192.168.100.21',
'username': 'Cisco',
'password': 'Cisco',
'secret':'Cisco',
'session_log': 'log.txt'
}
##opening IP file
ipfile=open("iplist.txt")
print ("Script to take backup of devices, Please enter your credential")
device['username']=input("username ")
device['password']=getpass.getpass()
print("Enter enable password: ")
device['secret']=getpass.getpass()enter code here
##taking backup
for line in ipfile:
try:
device['ip']=line.strip("\n")
print("\n\nConnecting Device ",line)
net_connect = ConnectHandler(**device)
net_connect.enable()
time.sleep(1)
with open('config.txt') as f:
cmd = f.read().splitlines()
print ("Reading the running config ")
output = net_connect.send_config_set(cmd)
output4 = "Failed"
time.sleep(7)
filename=device['ip']+'-'+today+".txt"
folder = os.path.join(today)
file = os.path.join(folder,filename)
os.makedirs(folder,exist_ok=True)
saveconfig=open(file,'w+')
print("Writing Configuration to file")
saveconfig.write(output)
saveconfig.close()
time.sleep(10)
net_connect.disconnect()
print ("Configuration saved to file",filename)
except:
print ("Access to "+device['ip']+" failed,backup did not taken")
output4 = "Failed"
file= device['ip']+'-'+today+"Error"+".txt"
config=open(file,'w+')
config.write(output4)
config.close()
ipfile.close()
print ("\nAll device backup completed")enter code here
You can refer below script and modify it according to your requirement. Here I have used python multiprocessing for connecting devices in pools.
#This script will allow for user pick hosts and enter show commands interactively
#
#Enable Multiprocessing
from multiprocessing import Pool
#
#getpass will not display password
from getpass import getpass
#ConnectionHandler is the function used by netmiko to connect to devices
from netmiko import ConnectHandler
#Time tracker
from time import time
#create variables for username and password
#create variables for configs and hosts
uname = input("Username: ")
passwd = getpass("Password: ")
cmd = input("Enter show commands seperated by ',': ")
host = input("Enter the host IPs seperate with space: ")
#This will put hosts and commands entered into list format
hosts = host.split()
cmds = cmd.split(",")
starting_time = time()
#Each member of the pool of 5 will be run through this function
def run_script(host_ip):
ios_rtr = {
"device_type": "cisco_ios",
"ip": host_ip,
"username": uname,
"password": passwd,
}
#connect to the device via ssh
net_connect = ConnectHandler(**ios_rtr)
#print the device IP or Hostname
print("Connected to host:", host_ip)
#this for loop is used to iterate through the show commands
for show_commands in cmds:
output = net_connect.send_command(show_commands)
print("Connected to host:", host_ip)
print(output)
print('\n---- Elapsed time=', time()-starting_time)
if __name__ == "__main__":
# Pool(5) means 5 process will be run at a time, more hosts will go in the next group
with Pool(5) as p:
print(p.map(run_script, hosts))
#This is the key to sending show commands vs config commands
#show commands --> net_connect.send_command()
#config commmands --> net_connect.send_config_set()
With this code, you can run commands on many devices at the same time. You can also use it by hiding your identity information with user_pass. There is also a device prompt discovery feature.
with open("user_pass.txt", "r") as f5:
user_pass = f5.readlines()
for list_user_pass in user_pass:
if "username" in list_user_pass:
username = list_user_pass.split(":")[1].strip()
if "password" in list_user_pass:
password = list_user_pass.split(":")[1].strip()
def _ssh_(nodeip):
try:
access_mpls = {
'device_type': 'huawei_olt', 'ip': nodeip, 'username':
username, 'password': password, }
net_connect = Netmiko(**access_mpls)
print(nodeip.strip() + " " + "success enter")
except Exception as e:
print(e)
f_3.write(nodeip.strip() + "\n")
return
prompt_gpon_fnk = net_connect.find_prompt()
hostname_fnk = prompt_gpon_fnk.strip("<" + ">")
print(hostname_fnk)
net_connect.send_command_timing("enable")
net_connect.send_command_timing("undo smart")
output = net_connect.send_command_timing("config")
print("config moda girildi")
net_connect.send_command_timing("acl 2010 ")
net_connect.send_command_timing("quit")
net_connect.send_command_timing("save")
print("config done")
with open("MDU_OK_2.txt", "a") as f:
f.write(nodeip + "\n")
f.close()
net_connect.disconnect()
f_2 = open("ip_list_2.txt", "r") ip_list = f_2.readlines()
f_2.close() f_3 = open("ssh_unsuccess_2.txt", "w")
myPool = ThreadPool(100) result = myPool.map(ssh, ip_list)
I have a code that tries to open the SAP GUI application and after putting the user's credentials, it runs a transaction and downloads the .xlsx file on the local.
In the second part of the code which is the exact .vbs script that I recorded in SAP GUI and pasted in Spyder.
I get a syntax error at the line if not IsObject(application) Then, how to solve it?
NB: I tried to use the same indentation as I used in Spyder after several edits.
< Importing the Libraries >
import win32com.client
import sys
import subprocess
import time
##This function will Login to SAP from the SAP Logon window
def saplogin():
try:
path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(10)
SapGuiAuto = win32com.client.GetObject('SAPGUI')
if not type(SapGuiAuto) == win32com.client.CDispatch:
return
application = SapGuiAuto.GetScriptingEngine
if not type(application) == win32com.client.CDispatch:
SapGuiAuto = None
return
connection = application.OpenConnection("=PR1 [Assembly & Test] router 1", True)
if not type(connection) == win32com.client.CDispatch:
application = None
SapGuiAuto = None
return
session = connection.Children(0)
if not type(session) == win32com.client.CDispatch:
connection = None
application = None
SapGuiAuto = None
return
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "UName"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "Pass"
session.findById("wnd[0]").sendVKey(0)
##This part is the SAP .vbs script which is recorded in the SAP and pasted here as-is: **>
if not IsObject(application) Then ##here I get the invalid syntax error.
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End if
if not IsObject(connection) Then
Set connection = application.Children(0)
End if
if not IsObject(session) Then
Set session = connection.Children(0)
End if
if IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End if
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "SPT52"
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/chkP_17REQS").selected = false
session.findById("wnd[0]/usr/chkP_18REQS").selected = false
session.findById("wnd[0]/usr/chkP_10REQS").selected = false
session.findById("wnd[0]/usr/chkP_ENGINE").selected = false
session.findById("wnd[0]/usr/chkP_DETAIL").selected = false
session.findById("wnd[0]/usr/radRB_FILE").select
session.findById("wnd[0]/usr/ctxtP_PLANT").text = "0010"
session.findById("wnd[0]/usr/ctxtPD_SEL-LOW").text = "86A"
session.findById("wnd[0]/usr/txtP_FDAY2").text = "0"
session.findById("wnd[0]/usr/txtP_WEEK2").text = "52"
session.findById("wnd[0]/usr/txtP_MONTH2").text = "0"
session.findById("wnd[0]/usr/txtP_FDAY2").setFocus
session.findById("wnd[0]/usr/txtP_FDAY2").caretPosition = 3
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[2]").close
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\Users\Documents\SAP\SAP GUI\"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "SP032.xls"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").setFocus
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 8
session.findById("wnd[1]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
except:
print(sys.exc_info()[0])
finally:
session = None
connection = None
application = None
SapGuiAuto = None
saplogin()
I did the changes after Sandra Rossi's comment as following but get a new error:
import win32com.client
import sys
import subprocess
import time
This function will Login to SAP from the SAP Logon window
try:
path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(2)
SapGuiAuto = win32com.client.GetObject('SAPGUI')
if not type(SapGuiAuto) == win32com.client.CDispatch:
return
application = SapGuiAuto.GetScriptingEngine
if not type(application) == win32com.client.CDispatch:
SapGuiAuto = None
return
connection = application.OpenConnection("=PR1 [Assembly & Test] router 1", True)
if not type(connection) == win32com.client.CDispatch:
application = None
SapGuiAuto = None
return
session = connection.Children(0)
if not type(session) == win32com.client.CDispatch:
connection = None
application = None
SapGuiAuto = None
return
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "Uname"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "Pass"
session.findById("wnd[0]").sendVKey(0)
session.findById("wnd[0]").resizeWorkingPane (98,16,False)
session.findById("wnd[0]/tbar[0]/okcd").text = "SP032"
session.findById("wnd[0]").sendVKey (0)
session.findById("wnd[0]/usr/radP_MATL").select
session.findById("wnd[0]/usr/chkP_LTPC").selected = False
session.findById("wnd[0]/usr/ctxtS_FEVOR-LOW").text = "86A"
session.findById("wnd[0]/usr/radP_SORT3").setFocus
session.findById("wnd[0]/usr/radP_SORT3").select
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr").verticalScrollbar.position = 1
session.findById("wnd[0]/usr").verticalScrollbar.position = 2
session.findById("wnd[0]/usr").verticalScrollbar.position = 3
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[2]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "D:\86A"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "SP032.txt"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 9
session.findById("wnd[1]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
saplogin()
IndentationError: unexpected unindent
Note: As I mentioned in my comments I did a lot of modification but after last one still the weird error comes back as **IndentationError: unexpected unindent
Some simple code like method call or attribute initialization has the same syntax in VBScript and Python but the rest is not compatible.
For instance, you have to make these adaptations (taken from Stefan Schnell blog post):
Python (the equivalent VBScript code is commented out):
#session.findById("wnd[0]").resizeWorkingPane 173, 36, 0
session.findById("wnd[0]").resizeWorkingPane(173, 36, 0)
#session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16"
#session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey(0)
#session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TADIR"
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").text = "TADIR"
#session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey(0)
#session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press()
Now it seems that the part of code which has not a valid Python syntax is not even needed because you already initialized the variables! These are the following lines to be removed from your script:
if not IsObject(application) Then ##here I get the invalid syntax error.
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End if
if not IsObject(connection) Then
Set connection = application.Children(0)
End if
if not IsObject(session) Then
Set session = connection.Children(0)
End if
if IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End if
Concerning the indentation issue, there are many questions and answers in StackOverflow.
I am attempting to use chrome with a user pass proxy this is my code:
def getProxy(string_only=True):
try:
proxy_manager = ProxyManager("proxies.txt")
proxy = proxy_manager.random_proxy()
if string_only:
return proxy.proxy_string
return proxy.get_dict()
except (OSError, IOError, IndexError) as e: # couldn't load the file / file is empty
return None
chrome_options = webdriver.ChromeOptions()
proxy = getProxy()
userpass = proxy[0:proxy.find("#")]
hostport = proxy[proxy.find("#")+1:]
if proxy:
chrome_options.add_argument("--proxy-server=" + hostport)
driver1 = webdriver.Chrome(chrome_options=chrome_options)
wait = WebDriverWait(driver1, 1000000)
if manual == "No":
driver1.get("http://%s#www.google.com"%userpass)
Help is appreciated
So I found this script online, which is meant to brute-force web-forms online etc. using Selenium, and I thought it would be a good idea to take it, modify it a bit and experiment with it. This time, I tried creating a bot that:
Signs up to Twitter
Goes to twitter.com
Posts something.
Logs out.
Loop 1, 2, 3, 4 again
However, when I run the script, it just pops up a browser window and does nothing. Then the Terminal ends the Python script like it did its work correctly and finished with no problems...
Code (note that the script might look weird for what I want, but that's because I found the script as a web-form brute-forcer online, and decided to modify it to my needs):
#!/bin/python
from mainLib import *
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import simplejson as json
import sys
import optparse
profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36")
driver = "reserved"
def userExists(username):
try:
driver.get("https://twitter.com/"+username)
assert (("??" or "?Twitter / ?") not in driver.title)
except AssertionError:
print '\033[1;31mUser\033[1;m',
print '\033[1;35m#%s\033[1;m' %username,
print '\033[1;31mdoes not exist.\033[1;m',
print '\033[1;33mTrying with the next Username...\033[1;m'
print ' '
return 1
except:
'uknown error'
def login(user, password, delay):
try:
print '\033[1;33mCreating account with mail: \033[1;m' + '\033[1;35m' + password + '\033[1;m' '\033[1;33m ...\033[1;m'
sleep(2)
if driver.current_url == 'https://twitter.com':
print '\033[1;33mPlease retry using a different IP Address (Proxy/VPN).\033[1;m'
driver.get("https://twitter.com/signup")
if driver.title == "Login on Twitter":
driver.get("https://twitter.com/signup")
sleep(3)
elem = driver.find_element_by_id('full-name')
elem.clear()
elem.send_keys('john')
elem = driver.find_element_by_id('email')
elem.clear()
elem.send_keys(password)
elem = driver.find_element_by_id('password')
elem.clear()
elem.send_keys("twitter1")
sleep(3)
elem.send_keys(Keys.RETURN)
sleep(delay + 3)
if driver.title == "Twitter / Error":
print ' \033[1;31mFailed!\033[1;m'
driver.get("https://twitter.com/signup")
sleep(3)
if driver.title == "Login to Twitter":
print ' \033[1;31mFailed!\033[1;m'
driver.get("https://twitter.com/signup")
sleep(3)
# if "This email is already registered." in driver.page_source:
# print ' \033[1;31mFailed!\033[1;m'
if driver.current_url == 'https://twitter.com/account/access':
print ' \033[1;31mFailed!\033[1;m'
print ("")
print '\033[1;33mPlease retry using a different IP Address (Proxy/VPN).\033[1;m'
driver.close()
sys.exit("")
assert (("Enter your phone") not in driver.title)
except AssertionError:
print ' \033[1;32mSuccess!\033[1;m'
# print '\033[1;35mEmail: \033[1;m' + password
# print '\033[1;35mPassword: \033[1;m' + "twitter1"
# print("")
try:
f = open('CreatedAccounts.txt','a')
except:
f = open('CreatedAccounts.txt','w')
f.write(password+'\n')
f.close()
driver.get("https://twitter.com")
elem = driver.find_element_by_id('tweet-box-home-timeline')
elem.clear()
elem.send_keys('It worked!')
elem = driver.find_element_by_xpath('//*[#id="timeline"]/div[2]/div/form/div[2]/div[2]/button')
elem.send_keys(Keys.RETURN)
time.sleep(5)
driver.get("https://twitter.com/logout")
sleep(5)
elem = driver.find_element_by_css_selector("button.js-submit").click()
sleep(5)
driver.get("https://twitter.com/signup")
# driver.delete_all_cookies()
# return 1
# else:
# print '\033[1;33mPlease check your Internet Connection.\033[1;m'
def dictionaryAttack(usernames,passwords,delay):
if str(type(usernames)) == "<type 'list'>":
for username in usernames:
#if (userExists(username) == 1):
# continue
driver.get("https://twitter.com/signup")
sleep(delay)
print("Creating Accounts...")
print("")
for password in passwords:
if (login(username,password,delay) == 1):
cj.clear()
break
def main():
parser = optparse.OptionParser()
parser.add_option('-f', '--file', action="store", dest="userfile", help="File containing valid usernames (one per line)", default=False)
parser.add_option('-d', '--dictionary', action="store", dest="dictionary", help="Text file containing passwords", default=False)
parser.add_option('-u', '--username', action="store", dest="username", help="A valid username", default=False)
parser.add_option('-t', '--time', action="store", dest="delay", help="Delay (in seconds) - use this option based on your Network Connection speed.", default=True)
options, args = parser.parse_args()
global driver
if (options.delay is None):
delay = 4
else:
delay = int(options.delay)
print '\033[1;33mUsing\033[1;m',
print '\033[1;35m%d second(s)\033[1;m' %delay,
print '\033[1;33mof delay between login attempts.\033[1;m'
print ' '
if ( (options.userfile == False) and (options.username == False) ) :
print 'You have to set an username or a userfile'
exit()
if ( (options.userfile != False) and (options.username != False) ) :
print 'You can\'t set both options at once.. choose between username or userfile'
exit()
if (options.dictionary == False):
print 'You have to set a valid path for the passwords dictionary.'
exit()
try:
f = open(options.dictionary,'r')
passwords = []
while True:
line = f.readline()
if not line:
break
passwords.append(line.strip('\n'))
f.close()
except:
print 'Check the path to the dictionary and try again.'
exit()
if (options.userfile != False):
try:
f = open(options.userfile,'r')
usernames = []
while True:
line = f.readline()
if not line:
break
usernames.append(line.strip('\n'))
f.close()
except:
print 'Check the path to the users file and try again.'
exit()
driver = webdriver.Firefox(profile)
driver.implicitly_wait(30)
dictionaryAttack(usernames,passwords,delay)
else:
driver = webdriver.Firefox(profile)
driver.implicitly_wait(30)
dictionaryAttack(options.username,passwords,delay)
driver.close()
if __name__ == '__main__':
main()
See the link below. That could be the problem.
https://github.com/SeleniumHQ/selenium/issues/2257
I am writing a python script to get logged in using ftp and download a file.But whenever I run this script,it says I have provided wrong user name or passwd.I am inputting right password still i am unable to run this script.My code is:
import os,getpass
from urllib.request import urlopen
filename='68544.jpg'
password=getpass.getpass('??')
At this line below the script is failed to run and whenever i run this address in browser it runs fine.
remoteaddr='ftp://Kamal:%s#localhost/%s;type=i'%(password,filename)
remotefile=urlopen(remoteaddr)
localfile=open(filename,'wb')
localfile.write(remotefile.read())
localfile.close()
remotefile.close()
def ftp_connect(path):
link = FTP(host = 'example.com', timeout = 5) #Keep low timeout
link.login(passwd = 'ftppass', user = 'ftpuser')
debug("%s - Connected to FTP" % strftime("%d-%m-%Y %H.%M"))
link.cwd(path)
return link
downloaded = open('/local/path/to/file.tgz', 'wb')
def debug(txt):
print txt
link = ftp_connect(path)
file_size = link.size(filename)
max_attempts = 5 #I dont want death loops.
while file_size != downloaded.tell():
try:
debug("%s while > try, run retrbinary\n" % strftime("%d-%m-%Y %H.%M"))
if downloaded.tell() != 0:
link.retrbinary('RETR ' + filename, downloaded.write, downloaded.tell())
else:
link.retrbinary('RETR ' + filename, downloaded.write)
except Exception as myerror:
if max_attempts != 0:
debug("%s while > except, something going wrong: %s\n \tfile lenght is: %i > %i\n"(strftime("%d-%m-%Y %H.%M"), myerror, file_size, downloaded.tell()))
link = ftp_connect(path)
max_attempts -= 1
else:
break
debug("Done with file, attempt to download m5dsum")
[...]
Use Paramiko library
import paramiko
paramiko.util.log_to_file('/tmp/paramiko.log')
# Open a transport
host = "example.com"
port = 22
transport = paramiko.Transport((host, port))
# Auth
password = "foo"
username = "bar"
transport.connect(username = username, password = password)
# Go!
sftp = paramiko.SFTPClient.from_transport(transport)
# Download
### It is relative path from the folder path on which this sftp user has default rights.
filepath = 'folder/file1.txt'
localpath = '/opt/backup/file.txt'
sftp.get(filepath, localpath)
# Close
sftp.close()
transport.close()