scripting

CMD.EXE batch script to display last 10 lines from a txt file

三世轮回 提交于 2019-12-17 07:16:09
问题 Any ideas how to echo or type the last 10 lines of a txt file? I'm running a server change log script to prompt admins to state what they're doing, so we can track changes. I'm trying to get the script to show the last 10 entries or so to give an idea of what's been happening recently. I've found a script that deals with the last line, as shown below, but can't figure out what to change in it to display the last 10 lines. Script: @echo off setLocal EnableDelayedExpansion for /f "tokens=*

Adding scripting functionality to .NET applications

久未见 提交于 2019-12-17 07:11:00
问题 I have a little game written in C#. It uses a database as back-end. It's a trading card game, and I wanted to implement the function of the cards as a script. What I mean is that I essentially have an interface, ICard , which a card class implements ( public class Card056: ICard ) and which contains function that is called by the game. Now, to make the thing maintainable/moddable, I would like to have the class for each card as source code in the database and essentially compile it on first

How to run a script at a certain time on Linux? [closed]

痴心易碎 提交于 2019-12-17 07:04:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a text file containing a specific date and time. I want to be able to run a script at the time specified in that file. How would you achieve that? Create another script that runs in background (sort of a deamon) and checks every second if the current time is matching the time in the file? Is there another

Sql*plus always returns exit code 0?

本小妞迷上赌 提交于 2019-12-17 06:52:24
问题 Whenever I run a sql script using Sql*plus and check for $?, I get 0 even when the script wasn't succesful. Example #$ sqlplus user/password@instance @script.sql SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 7 14:20:44 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.8.0 - Production v$dataf-ile d, * ERROR at line 6:

Sql*plus always returns exit code 0?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 06:52:21
问题 Whenever I run a sql script using Sql*plus and check for $?, I get 0 even when the script wasn't succesful. Example #$ sqlplus user/password@instance @script.sql SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 7 14:20:44 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.8.0 - Production v$dataf-ile d, * ERROR at line 6:

Get just the filename from a path in a Bash script [duplicate]

浪尽此生 提交于 2019-12-17 06:23:19
问题 This question already has answers here : Extract filename and extension in Bash (37 answers) Closed 2 years ago . How would I get just the filename without the extension and no path? The following gives me no extension, but I still have the path attached: source_file_filename_no_ext=${source_file%.*} 回答1: Most UNIX-like operating systems have a basename executable for a very similar purpose (and dirname for the path): pax> a=/tmp/file.txt pax> b=$(basename $a) pax> echo $b file.txt That

How do I get the current username in Windows PowerShell?

你离开我真会死。 提交于 2019-12-17 06:23:11
问题 How do I get the current username in Windows PowerShell? 回答1: I found it: $env:UserName There is also: $env:UserDomain $env:ComputerName 回答2: [System.Security.Principal.WindowsIdentity]::GetCurrent().Name 回答3: I thought it would be valuable to summarize and compare the given answers. If you want to access the environment variable : (easier/shorter/memorable option) [Environment]::UserName -- @ThomasBratt $env:username -- @Eoin whoami -- @galaktor If you want to access the Windows access token

Get just the filename from a path in a Bash script [duplicate]

泄露秘密 提交于 2019-12-17 06:22:59
问题 This question already has answers here : Extract filename and extension in Bash (37 answers) Closed 2 years ago . How would I get just the filename without the extension and no path? The following gives me no extension, but I still have the path attached: source_file_filename_no_ext=${source_file%.*} 回答1: Most UNIX-like operating systems have a basename executable for a very similar purpose (and dirname for the path): pax> a=/tmp/file.txt pax> b=$(basename $a) pax> echo $b file.txt That

Get name of current script in Python

99封情书 提交于 2019-12-17 05:23:21
问题 I'm trying to get the name of the Python script that is currently running. I have a script called foo.py and I'd like to do something like this in order to get the script name: print Scriptname 回答1: Use __file__ . If you want to omit the directory part (which might be present), you can use os.path.basename(__file__) . 回答2: import sys print sys.argv[0] This will print foo.py for python foo.py , dir/foo.py for python dir/foo.py , etc. It's the first argument to python . (Note that after py2exe

Get name of current script in Python

放肆的年华 提交于 2019-12-17 05:22:12
问题 I'm trying to get the name of the Python script that is currently running. I have a script called foo.py and I'd like to do something like this in order to get the script name: print Scriptname 回答1: Use __file__ . If you want to omit the directory part (which might be present), you can use os.path.basename(__file__) . 回答2: import sys print sys.argv[0] This will print foo.py for python foo.py , dir/foo.py for python dir/foo.py , etc. It's the first argument to python . (Note that after py2exe