scripting

VB Script does not recognize the actual parameter

流过昼夜 提交于 2020-01-11 13:01:15
问题 I've two VB Scripts. Say First.vbs and Second.vbs . Frist.vbs calls Second.vbs each time some action/event happens. I am trying to send two parameters from Frist.vbs to Second.vbs using the following code: Contents of First.vbs : Set objShell = Wscript.CreateObject("WScript.Shell") param1 = "Welcome" param2 = "Gokul Nath" objShell.Run "Second.vbs" & " " & param1 & " " & param2 Set objShell = Nothing Contents of Second.vbs : param1= Wscript.Arguments.Item(0) param2 = Wscript.Arguments.Item(1)

Detecting failure of a Bash “export” value

江枫思渺然 提交于 2020-01-11 09:20:49
问题 In Bash I'm executing a command and putting the result in a variable like this: export var=`svn ls` But if SVN fails for some reason--say it returns a non-zero error code--export still returns status code 0. How do I detect if the executed command fails? 回答1: var=`svn ls` if [[ $? == 0 ]] then export var else unset var fi $? is the exit code of the last command executed, which is svn ls here. jmohr's solution is short and sweet. Adapted mildly, var=`svn ls` && export var || unset var would be

WinSCP - How to recognize if file was transferred successfully

浪尽此生 提交于 2020-01-11 07:40:12
问题 I'm using WinSCP to automatically upload files through SFTP. I have turned on debug log on level 1. Is it possible to find out if the file was uploaded successfully? Thank you. Part of log file: . 2012-08-30 15:30:06.539 File: "C:\files\file_20120830.gpg" . 2012-08-30 15:30:06.539 Copying "C:\files\file_20120830.gpg" to remote directory started. . 2012-08-30 15:30:06.539 Binary transfer mode selected. . 2012-08-30 15:30:06.539 Checking existence of file. > 2012-08-30 15:30:06.539 Type: SSH

Can I Pass Arguments To A Powershell Function The Unix Way?

末鹿安然 提交于 2020-01-11 05:40:08
问题 I have a PowerShell function that basically looks like this: function DoSomething-ToTask { [cmdletbinding()] param( [parameter(Mandatory=$true)] [strehg[]]$TaskNums ) foreach ($TaskNum in $TaskNums) { do something $TaskNum } } The goal is to be able to be able to call this function from the command line with an arbitrary number of parameters. For example, I may call it like this now: DoSomething-ToTask 1 2 3 ..and like this later DoSomething-ToTask 4 The second example works, but the first

AutoHotKey: Calling one script from another script

本小妞迷上赌 提交于 2020-01-11 04:34:10
问题 I just discovered AutoHotKey and it seems like a dream come true. I have two .ahk scripts, A.ahk and B.ahk . I want to call script B from within script A. The AHK forums are strangely silent on the subject but I am sure this is possible. 回答1: It's the #Include directive you are looking for. You include ScriptB.ahk, then call its functions like you normally would. #include SomeFile.ahk http://www.autohotkey.com/docs/commands/_Include.htm 回答2: Using an #include directive is more common, but

Change directory to the directory of a Python script [duplicate]

本秂侑毒 提交于 2020-01-10 10:24:48
问题 This question already has answers here : How do I change the working directory (cd) in Python? (12 answers) Closed 11 months ago . How do i change directory to the directory with my python script in? So far I figured out I should use os.chdir and sys.argv[0] . I'm sure there is a better way then to write my own function to parse argv[0]. 回答1: os.chdir(os.path.dirname(__file__)) 回答2: os.chdir(os.path.dirname(os.path.abspath(__file__))) should do it. os.chdir(os.path.dirname(__file__)) would

Change directory to the directory of a Python script [duplicate]

放肆的年华 提交于 2020-01-10 10:24:25
问题 This question already has answers here : How do I change the working directory (cd) in Python? (12 answers) Closed 11 months ago . How do i change directory to the directory with my python script in? So far I figured out I should use os.chdir and sys.argv[0] . I'm sure there is a better way then to write my own function to parse argv[0]. 回答1: os.chdir(os.path.dirname(__file__)) 回答2: os.chdir(os.path.dirname(os.path.abspath(__file__))) should do it. os.chdir(os.path.dirname(__file__)) would

Change directory to the directory of a Python script [duplicate]

狂风中的少年 提交于 2020-01-10 10:24:03
问题 This question already has answers here : How do I change the working directory (cd) in Python? (12 answers) Closed 11 months ago . How do i change directory to the directory with my python script in? So far I figured out I should use os.chdir and sys.argv[0] . I'm sure there is a better way then to write my own function to parse argv[0]. 回答1: os.chdir(os.path.dirname(__file__)) 回答2: os.chdir(os.path.dirname(os.path.abspath(__file__))) should do it. os.chdir(os.path.dirname(__file__)) would

VBA: How to display an error message just like the standard error message which has a “Debug” button?

大城市里の小女人 提交于 2020-01-10 07:54:30
问题 As usual, I create an error-handler using On Error Goto statement, there I put a few lines of cleaning codes and display the error message, but now I don't want to lose the comfortableness of the default handler which also point me to the exact line where the error has occured. How can I do that? Thanks in advance. 回答1: First the good news. This code does what you want (please note the "line numbers") Sub a() 10: On Error GoTo ErrorHandler 20: DivisionByZero = 1 / 0 30: Exit Sub ErrorHandler:

search multiple pattern in file and delete line if pattern matches

删除回忆录丶 提交于 2020-01-10 03:09:06
问题 For ex, a file contain contents: 10.45.56.84 raj 10.49.31.81 mum 10.49.31.86 mum 10.81.51.92 guj 10.45.56.116 raj 10.45.56.84 raj I want to search 10.45.56.84 and 10.81.51.92 in the above file and delete line if pattern matches. Also i want to do this in single command. 回答1: Another solution: awk '!/10.45.56.84|10.81.51.92/' file 回答2: grep -Fv -f <(echo $'10.45.56.84\n10.81.51.92') filename 回答3: You could do this: sed -e '/10[.]45[.]56[.]84/d;/10[.]81[.]51[.]92/d' file This has two sed "d"