scripting

Bash script issue

谁说胖子不能爱 提交于 2020-01-24 10:37:10
问题 I can run this command fine, with the output I want: ifconfig eth0 | grep HWaddr | awk '{print $5}' However, when I set the command to a variable, and print the variable, I get an error: CASS_INTERNAL=`ifconfig eth0 | grep HWaddr | awk '{print \$5}'` $CASS_INTERNAL my internal xxx ip: command not found The weird thing - my internal IP actually shows up. How do I go about this without getting an error? It shouldn't matter, but I'm using the latest version of Ubuntu. 回答1: Well, you grep for

Bash script issue

不羁的心 提交于 2020-01-24 10:37:06
问题 I can run this command fine, with the output I want: ifconfig eth0 | grep HWaddr | awk '{print $5}' However, when I set the command to a variable, and print the variable, I get an error: CASS_INTERNAL=`ifconfig eth0 | grep HWaddr | awk '{print \$5}'` $CASS_INTERNAL my internal xxx ip: command not found The weird thing - my internal IP actually shows up. How do I go about this without getting an error? It shouldn't matter, but I'm using the latest version of Ubuntu. 回答1: Well, you grep for

Command-line dialog tool for Windows

喜你入骨 提交于 2020-01-24 03:13:06
问题 I need a dialog tool similar to cdialog (or whiptail), but one that will work on Windows. I have MinGW and compiling something from source is no problem, but both cdialog and whiptail, the only ones that I know of, contain code that is UNIX-specific, and so they will not compile on Windows. Are there any alternatives that I can use? I'd rather not have to figure out and replace the platform-specific code myself. 回答1: I remember the E Text Editor using wxCocoaDialog for that purpose:

Batch convert DDS file to DDS without mipmaps

主宰稳场 提交于 2020-01-24 00:50:14
问题 I have a Mount & Blade: Warband mod called 1257 AD. The mod itself is great, but all the textures have to be resaved to remove mipmaps from dds files, to remove glitches on GNU/Linux. And of course, I could do this manually, but it will took a lot of time(over 2000 textures), and is there any way for gimp to just open and save the file without mipmaps. Also, last time I wanted to do this I used loop with Imagemagicks convert, but it kept mipmaps. So how do I do this kind of convert? 回答1: You

ElementTree Remove Element

≡放荡痞女 提交于 2020-01-23 12:22:13
问题 Python noob here. Wondering what's the cleanest and best way to remove all the " profile " tags with updated attribute value of true . I have tried the following code but it's throwing: SyntaxError("cannot use absolute path on element") root.remove(root.findall("//Profile[@updated='true']")) XML: <parent> <child type="First"> <profile updated="true"> <other> </other> </profile> </child> <child type="Second"> <profile updated="true"> <other> </other> </profile> </child> <child type="Third">

ElementTree Remove Element

大城市里の小女人 提交于 2020-01-23 12:18:47
问题 Python noob here. Wondering what's the cleanest and best way to remove all the " profile " tags with updated attribute value of true . I have tried the following code but it's throwing: SyntaxError("cannot use absolute path on element") root.remove(root.findall("//Profile[@updated='true']")) XML: <parent> <child type="First"> <profile updated="true"> <other> </other> </profile> </child> <child type="Second"> <profile updated="true"> <other> </other> </profile> </child> <child type="Third">

Crawl website using wget and limit total number of crawled links

佐手、 提交于 2020-01-23 11:14:27
问题 I want to learn more about crawlers by playing around with the wget tool. I'm interested in crawling my department's website, and finding the first 100 links on that site. So far, the command below is what I have. How do I limit the crawler to stop after 100 links? wget -r -o output.txt -l 0 -t 1 --spider -w 5 -A html -e robots=on "http://www.example.com" 回答1: You can't. wget doesn't support this so if you want something like this, you would have to write a tool yourself. You could fetch the

Setting up an 'environment' for an embedded Lua Script

混江龙づ霸主 提交于 2020-01-23 08:26:48
问题 I am embedding a Lua interpreter in a C++ application. I want to setup an 'environment' for running scripts, such that certain variables are made available to all scripts. For example, I want to expose READ ONLY objects Foo and FooBar to scripts, such that Foo and FooBar are available to all running scripts. Does anyone know how I can do this?. A snippet to show how to so this would be very useful. 回答1: I haven't heard of read-only variables in Lua but you can prevent modification by making

Sending an email automatically when the edited cell value says “Done” and the email subject is the first cell in the edited row

萝らか妹 提交于 2020-01-23 04:13:10
问题 I'm trying to write a script where an automatic email is sent to a specific person upon edit of a cell and the cell equals "Done". However, I want the subject to be the first cell of the edited row. Cell that will contain "Done" is always going to be in the AA Column, and I want the subject to be the A column of the same row. Ex: AA3 was edited so subject is A3. I have spent hours sifting through tutorials and came up with this: function checkValue() { var sp = PropertiesService

Bash Scripting and bc

旧时模样 提交于 2020-01-22 17:43:07
问题 I'm trying to write a bash script and I needed to do some floating point math. Basically I want to do something like this: NUM=$(echo "scale=25;$1/10" | bc) if [ $? -ne 0 ] then echo bad fi The problem I'm running into is $? tends to hold the output from the echo program and not the bc call. Is there a way I save the output from the bc program into a variable? EDIT: Thanks for the quick replies. Here's another way of looking at the problem. Say I modified the script a little bit so it looks