scripting

SQL Server - stop or break execution of a SQL script

我们两清 提交于 2019-12-17 02:52:38
问题 Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command? I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or lookups fail. 回答1: The raiserror method raiserror('Oh no a fatal error', 20, -1) with log This will terminate the connection, thereby stopping the rest of the script from running. Note that both severity level 20 or higher and the WITH LOG option are

When is a language considered a scripting language? [closed]

不问归期 提交于 2019-12-17 02:52:18
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. What makes a language a scripting language? I've heard some people say "when it gets interpreted

PHP - Redirect and send data via POST

亡梦爱人 提交于 2019-12-17 02:43:10
问题 I have an online gateway which requires an HTML form to be submitted with hidden fields. I need to do this via a PHP script without any HTML forms (I have the data for the hidden fields in a DB) To do this sending data via GET: header('Location: http://www.provider.com/process.jsp?id=12345&name=John'); And to do this sending data via POST? 回答1: You can't do this using PHP. As others have said, you could use cURL - but then the PHP code becomes the client rather than the browser. If you must

What does $$ mean in the shell?

时光毁灭记忆、已成空白 提交于 2019-12-17 02:27:15
问题 I once read that one way to obtain a unique filename in a shell for temp files was to use a double dollar sign ( $$ ). This does produce a number that varies from time to time... but if you call it repeatedly, it returns the same number. (The solution is to just use the time.) I am curious to know what $$ actually is, and why it would be suggested as a way to generate unique filenames. 回答1: In Bash $$ is the process ID, as noted in the comments it is not safe to use as a temp filename for a

Global environment variables in a shell script

老子叫甜甜 提交于 2019-12-17 02:10:52
问题 How to set a global environment variable in a bash script? If I do stuff like #!/bin/bash FOO=bar ...or #!/bin/bash export FOO=bar ...the vars seem to stay in the local context, whereas I'd like to keep using them after the script has finished executing. 回答1: Run your script with . . myscript.sh This will run the script in the current shell environment. export governs which variables will be available to new processes, so if you say FOO=1 export BAR=2 ./runScript.sh then $BAR will be

Remove the last line from a file in Bash

喜夏-厌秋 提交于 2019-12-17 02:00:50
问题 I have a file, foo.txt , containing the following lines: a b c I want a simple command that results in the contents of foo.txt being: a b 回答1: Using GNU sed: sed -i '$ d' foo.txt The -i option does not exist in GNU sed versions older than 3.95, so you have to use it as a filter with a temporary file: cp foo.txt foo.txt.tmp sed '$ d' foo.txt.tmp > foo.txt rm -f foo.txt.tmp Of course, in that case you could also use head -n -1 instead of sed . MacOS: On Mac OS X (as of 10.7.4), the equivalent

Execute command on all files in a directory

萝らか妹 提交于 2019-12-17 01:33:49
问题 Could somebody please provide the code to do the following: Assume there is a directory of files, all of which need to be run through a program. The program outputs the results to standard out. I need a script that will go into a directory, execute the command on each file, and concat the output into one big output file. For instance, to run the command on 1 file: $ cmd [option] [filename] > results.out 回答1: The following bash code will pass $file to command where $file will represent every

Driving Excel from Python in Windows

只愿长相守 提交于 2019-12-17 00:44:13
问题 We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python script to drive this. In other words, the python script will start up, load the excel sheet, and then interact with the sheet by making minor changes in some cells and seeing how they

Capture key press (or keydown) event on DIV element

我是研究僧i 提交于 2019-12-16 23:57:32
问题 How do you trap the keypress or key down event on a DIV element (using jQuery)? What is required to give the DIV element focus? 回答1: (1) Set the tabindex attribute: <div id="mydiv" tabindex="0" /> (2) Bind to keydown: $('#mydiv').on('keydown', function(event) { //console.log(event.keyCode); switch(event.keyCode){ //....your actions for the keys ..... } }); To set the focus on start: $(function() { $('#mydiv').focus(); }); To remove - if you don't like it - the div focus border, set outline:

How do I get the result of a command in a variable in windows?

喜夏-厌秋 提交于 2019-12-16 21:18:35
问题 I'm looking to get the result of a command as a variable in a Windows batch script (see how to get the result of a command in bash for the bash scripting equivalent). A solution that will work in a .bat file is preferred, but other common windows scripting solutions are also welcome. 回答1: If you have to capture all the command output you can use a batch like this: @ECHO OFF IF NOT "%1"=="" GOTO ADDV SET VAR= FOR /F %%I IN ('DIR *.TXT /B /O:D') DO CALL %0 %%I SET VAR GOTO END :ADDV SET VAR=