my ($match) = "some string" =~ /(some).*/; print $match; # prints "some"
Tuesday, September 11, 2018
Perl: How to capture a regex match in one line
Friday, March 17, 2017
Ten Years On
Just realized I've had this blog up on Blogger since February 2007.
My site isnow no longer hosted on GitHub pages at https://psteiner.com/
See youthere here!
[Edit - 11 Sept 2018: decided to move back, GitHub pages is too much work!]
My site is
See you
[Edit - 11 Sept 2018: decided to move back, GitHub pages is too much work!]
Sunday, March 5, 2017
Control+Shift+Enter to launch a Windows program as admin!
To launch any Windows program with elevated (admin) privileges, hold Control+Shift keys, then double-click the program's icon, even on the taskbar.
Alternatively, hit the Windows key, type the program name, e.g. cmd then type Control+Shift+Enter to launch the program with elevated (admin) privileges. You might have to enter admin credentials in the UAC popup.
See this LifeHacker article for more details.
Alternatively, hit the Windows key, type the program name, e.g. cmd then type Control+Shift+Enter to launch the program with elevated (admin) privileges. You might have to enter admin credentials in the UAC popup.
See this LifeHacker article for more details.
Wednesday, April 13, 2016
How to check for admin rights from a Windows batch file
Simple check for administrative permissions in a batch file:
REM Check for admin rights - net session must run as admin
net session >nul 2>&1
if %ErrorLevel% NEQ 0 (
echo You must right-click and select "RUN AS ADMINISTRATOR" to run this script.
echo.
pause
exit /B
)
REM Check for admin rights - net session must run as admin
net session >nul 2>&1
if %ErrorLevel% NEQ 0 (
echo You must right-click and select "RUN AS ADMINISTRATOR" to run this script.
echo.
pause
exit /B
)
Wednesday, February 17, 2016
Another HEREDOC style for Windows Batch Files
I wanted to pipe a SQL query to sqlplus in a batch file, without using a temp SQL file.
That technique involves echo'ing the SQL statements to a temp file, then call sqlplus on that file:
REM create the temp SQL file
echo SELECT USER >>temp.sql
echo FROM DUAL; >>temp.sql
REM execute sqlplus
sqlplus -S / @temp.sql
REM cleanup!
del temp.sql
An alternative is to wrap the echo statements in parentheses "( ... )", so they execute as a block, then pipe "|" the result to sqlplus:
(
echo SELECT USER
echo FROM DUAL;
) | sqlplus -S /
Admittedly, this is not much prettier than the first example, but it's self-contained, and doesn't leave random temp files that may or may not get cleaned up.
That technique involves echo'ing the SQL statements to a temp file, then call sqlplus on that file:
REM create the temp SQL file
echo SELECT USER >>temp.sql
echo FROM DUAL; >>temp.sql
REM execute sqlplus
sqlplus -S / @temp.sql
REM cleanup!
del temp.sql
An alternative is to wrap the echo statements in parentheses "( ... )", so they execute as a block, then pipe "|" the result to sqlplus:
(
echo SELECT USER
echo FROM DUAL;
) | sqlplus -S /
Admittedly, this is not much prettier than the first example, but it's self-contained, and doesn't leave random temp files that may or may not get cleaned up.
Friday, May 9, 2014
HEREDOC for Windows Batch Files
From Wikipedia: "In computer science, a here document (here-document, heredoc, hereis, here-string or here-script) is a file literal or input stream literal: it is a section of a source code file that is treated as if it were a separate file."
Here's one way to accomplish this in a Windows batch file. Inside the batch file, echo the text to an output redirection, e.g. "> here.txt". Use carets "^" followed by double linebreaks to output on separate lines:
here_test.bat
echo This is my ^
multi-line here document ^
that this batch file ^
will print! > here.txt
When executed here_text.bat will create a new file here.txt containing the lines of text:
Here's one way to accomplish this in a Windows batch file. Inside the batch file, echo the text to an output redirection, e.g. "> here.txt". Use carets "^" followed by double linebreaks to output on separate lines:
here_test.bat
echo This is my ^
multi-line here document ^
that this batch file ^
will print! > here.txt
When executed here_text.bat will create a new file here.txt containing the lines of text:
This is my
multi-line here document
that this batch file
will print!
multi-line here document
that this batch file
will print!
Monday, March 3, 2014
Subscribe to:
Posts (Atom)