scripting

Taking an argument from user (URL)

大城市里の小女人 提交于 2019-12-13 17:27:31
问题 Does anyone know how I would be able to take the the URL as an argument in Python as page? Just to readline in the script, user inputs into the shell and pass it through as an argument just to make the script more portable? import sys, re import webpage_get def print_links(page): ''' find all hyperlinks on a webpage passed in as input and print ''' print '\n[*] print_links()' links = re.findall(r'(\http://\w+\.\w+[-_]*\.*\w+\.*?\w+\.*?\w+\.*[//]*\.*?\w+ [//]*?\w+[//]*?\w+)', page) # sort and

Using source to include part of a file in a bash script

試著忘記壹切 提交于 2019-12-13 17:11:46
问题 I've a bash script that need to use some variables included in a separate file. Normally, for including the entire file I would use source otherfile.sh in the main script. In this case I need to use just a portion of this file. I can't use (include) the rest of the variables included in the rest of the file. To filter the content of the config file (let's say just as example from the tag "# start" to "# end") I use awk, but I can't redirect the output to the soruce command. Below my code: awk

“Access is denied” by executing .hta file with JScript on Windows XP x64

最后都变了- 提交于 2019-12-13 16:26:41
问题 I have a simple HTML (as HTA) application that shows strange behavior on Windows XP x64 machine. I getting periodically (not every time) error message "Access is denied." when I start the application. The same application on Windows XP 32bit runs just fine... Does somebody has any idea or explanation? Error message: Line: 18 Char: 6 Error: Access is denied. Code: 0 URL: file:///D:/test_j.hta Here is the code of my "test_j.hta": <html> <head> <title>Test J</title> <HTA:APPLICATION ID="objTestJ

How do you specify multiple AppleScript child elements of the same class?

谁说我不能喝 提交于 2019-12-13 16:02:02
问题 I'm adding Apple Event scripting to my application. I would like to be able to use both of the statements below on it: -- Every instance of MyObject in the app every MyObject -- Only the instances of MyObject the user has selected selected MyObjects These are relevant excerpts from of my sdef file: <dictionary> <suite ...> <class name="application" code="capp" description="Top-level scripting object" plural="applications" inherits="application"> <cocoa class="MyAppClass" /> <element type=

Execute php script every 40 milliseconds?

蹲街弑〆低调 提交于 2019-12-13 14:54:22
问题 There is some way to execute a php script every 40 milliseconds? I don't know if cronjob is the right way, because 25 times per second require a lot of CPU. Well, If php isn't the correct language, what language I should use? I am making a online game, but I need something to process what is happening in the game, to move the characters, to calculate projectiles paths, etc. 回答1: If you try to invoke a PHP script every 40 milliseconds, that will involve: Create a process Load PHP Load and

What does if (@array) mean in perl?

Deadly 提交于 2019-12-13 14:36:29
问题 What does this mean in Perl? if (@array) if (!@array) Does this mean if we ask Perl to check if array exists or not? Thanks 回答1: An array in scalar context returns the number of elements. So the if(@array) checks if the array has any elements or not. It's similar to if(scalar(@array)!=0) . 回答2: In Perl, an array in scalar context evaluates to the number of elements in the array. So my @array = ('a', 'b'); my $n = @array; sets $n to 2. Also, if applies a scalar context to its parameter. So my

Converting hexadecimal to decimal using awk or sed [duplicate]

北慕城南 提交于 2019-12-13 12:16:36
问题 This question already has answers here : Converting hex to decimal in awk or sed (7 answers) Closed 6 years ago . I have a data like this, with comma-separated: 18:22:05,OtherOMoperation,BatuAmpar,BatuAmparMG1,2fe3,c7b1 18:22:05,OtherOMoperation,BatuAmpar,BatuAmparMG2,2fe3,c7b2 18:22:05,OtherOMoperation,BatuAmpar,BatuAmparMG3,2fe3,c7b3 03:25:55,Othercauses,N_Pancamukti,N_PancamuktiMG1,2f50,c775 03:25:55,Othercauses,N_Pancamukti,N_PancamuktiMG2,2f50,c776 I need to convert last two columns into

Delete first line of text file

怎甘沉沦 提交于 2019-12-13 11:33:18
问题 I need a cmd script that deletes the first line in my text file. The scenario is the following: I take a txt file from FTP everyday, the problem is that it comes with blank line at the top then the headers of the file. Since I'm importing that file automatically into an access table, that blank line is causing me problems. So, I need a script that deletes the blank line and saves the file. 回答1: Windows/command prompt: more +1 filename.ext > otherfilename.ext That seems to work fine, however

Cygwin save package selections for later reinstall

跟風遠走 提交于 2019-12-13 11:32:32
问题 I was wondering if there is a way to save the current package selections for cygwin for a later reinstall or porting on a different system. It would be really great to: run a command to export a list of installed packages on an existing system pass the list to the installer on another system in a way such as setup-x86_64.exe --list list.txt I don't think the setup has such a switch, so even any type of script or batch working in this direction would be just fine. Since the number of needed

unix shell scripting subtraction for floating point numbers

孤街醉人 提交于 2019-12-13 10:20:01
问题 #!/bin/ksh a=8.3 b=10.20 diff=`expr $b - $a` echo "$diff" its giving expr: 0402-046 A specified operator requires numeric parameters. error i want output as 1.9 回答1: You don't need bc for this, use the native arithmetic operators in ksh #!/bin/ksh a=8.3 b=10.20 printf "%.2f\n" "$((b - a))" outputs $ ksh script.ksh 1.90 来源: https://stackoverflow.com/questions/41059906/unix-shell-scripting-subtraction-for-floating-point-numbers