scripting

How do I tell if a regular file does not exist in Bash?

可紊 提交于 2019-12-16 20:06:09
问题 I've used the following script to see if a file exists: #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi What's the correct syntax to use if I only want to check if the file does not exist? #!/bin/bash FILE=$1 if [ $FILE does not exist ]; then echo "File $FILE does not exist." fi 回答1: The test command ( [ here) has a "not" logical operator which is the exclamation point (similar to many other languages). Try this: if [ ! -f /tmp/foo

How do I tell if a regular file does not exist in Bash?

五迷三道 提交于 2019-12-16 20:06:09
问题 I've used the following script to see if a file exists: #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi What's the correct syntax to use if I only want to check if the file does not exist? #!/bin/bash FILE=$1 if [ $FILE does not exist ]; then echo "File $FILE does not exist." fi 回答1: The test command ( [ here) has a "not" logical operator which is the exclamation point (similar to many other languages). Try this: if [ ! -f /tmp/foo

Is there a simple way to convert C++ enum to string?

余生颓废 提交于 2019-12-16 19:53:11
问题 Suppose we have some named enums: enum MyEnum { FOO, BAR = 0x50 }; What I googled for is a script (any language) that scans all the headers in my project and generates a header with one function per enum. char* enum_to_string(MyEnum t); And a implementation with something like this: char* enum_to_string(MyEnum t){ switch(t){ case FOO: return "FOO"; case BAR: return "BAR"; default: return "INVALID ENUM"; } } The gotcha is really with typedefed enums, and unnamed C style enums. Does anybody

Is there a simple way to convert C++ enum to string?

谁说我不能喝 提交于 2019-12-16 19:53:03
问题 Suppose we have some named enums: enum MyEnum { FOO, BAR = 0x50 }; What I googled for is a script (any language) that scans all the headers in my project and generates a header with one function per enum. char* enum_to_string(MyEnum t); And a implementation with something like this: char* enum_to_string(MyEnum t){ switch(t){ case FOO: return "FOO"; case BAR: return "BAR"; default: return "INVALID ENUM"; } } The gotcha is really with typedefed enums, and unnamed C style enums. Does anybody

Batch File Querying Registry in 64-Bit Vista

a 夏天 提交于 2019-12-14 04:26:37
问题 Hi guys me again :) I have a problem with a batch file I wrote. It works fine on 32-bit, but apparently it doesn't work on 64-bit systems, and I don't know why because I do not have access to a 64-bit system. This is the code that works on Vista 32-bit system @echo off Set Reg.Key=HKLM\SOFTWARE\Malwarebytes' Anti-Malware Set Reg.Val=InstallPath For /F "Tokens=2*" %%A In ( 'Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' ) Do Call Set MBAMPATH=%%B Can someone re-write it to work

How to write a Cisco IOS script to run a set of commands at a certain time each day?

坚强是说给别人听的谎言 提交于 2019-12-14 04:23:44
问题 I am trying to write a tcl script that will delete and un-register certain policies in my router every morning, but when I try to upload it to the device it wont work. Here is what I have done so far; ::cisco::eem::event_register_timer cron name crontimer2 cron_entry $_cron_entry namespace import ::cisco::eem::* namespace import ::cisco::lib::* exec "en" exec "cd RuBAN" exec "delete syslogsyslog_fresh_install.tcl" exec "delete syslogsyslog_fresh_install.cfg" exec "delete marvin_fresh

Start-Job passing XML object to -ArgumentList working different in Powershell V2 & V3

我与影子孤独终老i 提交于 2019-12-14 03:52:44
问题 I'm testing a deployment script for my application on Windows Server 2012 with Powershell v3. The script runs fine on Win Server 2008 R2 and Win 7 with Powershell v2. The issue I'm running into now is that I can not access properties of XML variables passed via -ArgumentList. I've been able to reproduce the issue on Win 7 and Win Server 2012 with Powershell v3 in a simple script that doesn't have any of the SharePoint, IIS, misc that my main script does. Script (I think I borrowed this from a

How to get the IP Address of the Remote Desktop Client?

可紊 提交于 2019-12-14 03:46:29
问题 I'm trying to write a script to log the IP address of the Windows client from which the user initiated Remote Desktop to log in to the Windows Server. How to capture the IP address of the client in the Server? 回答1: So, you ignore proxy... using environment var: CLIENTNAME in domain you can resolve it back to IP without domain controller: using WMI script you can get to Event Log, source: Security, look for category Logon/Logoff where username = environment variable USERNAME 回答2: If you want

click() command not working on document.getElementsByClassName()

怎甘沉沦 提交于 2019-12-14 03:37:13
问题 Im making automated browser scripts with javascript and I want to use the click() command on this website but the button on the website doesnt have an Id (which works fine). However it only has a class name. When I do document.getElementsByClassName(btn.btn-danger.btn-lg.btn-block.betButton).click() it doesnt work. Here is the inspect of the button I want to click: <button class="btn btn-danger btn-lg btn-block betButton" data-color="r">1 to 7, Win x2</button> Is it possible to use the click(

Windbg scripting assigning the result of a command to a variable

北城余情 提交于 2019-12-14 03:26:26
问题 Regularly I need to investigate dumpfiles, always in the same way, and I'd like to automate this. I'm using Windbg as a tool, and I'm thinking of using Windbg scripting. I have done some first attempts with PYKD, but I don't like the overhead that much, so I've opted for the standard Windbg scripting, but this is getting into a nightmare, let me show you what I want to do: 0:001> kb # RetAddr : Args to Child : Call Site 00 00007ffc`26272685 : ffffffff`fffffffe 00007ff7`06e563f0 00007ff7