Tag Info

New answers tagged

0

Simple. In nslookup use: Set type=A Then lookup. The set command will show only outputs for A records. You can use this for MX, CNAME, AAA etc.


1

Assuming you are using Windows, this can be done using a simple one line command. The following will put your current public IP address in a file called ip.txt: for /f "skip=4 usebackq tokens=2" %a in (`nslookup myip.opendns.com resolver1.opendns.com`) do echo %a > ip.txt Note that the above command does not require non standard windows commands like ...


0

If you're on Windows, and have PowerShell installed (v1 or better) (and a .Net version) you could use a (long) one-liner like this: [System.Net.Dns]::GetHostAddresses("www.google.com")[0] | Select IPAddressToString -ExpandProperty IPAddressToString | Out-File c:\folder\filename.txt This will lookup www.google.com and put the first returned IPv4 address ...


0

If your goal is to retrieve your external IP with a script, a possible would be the use of a very simple PowerShell function : function Get-ExternalIP { (Invoke-WebRequest ifconfig.me/ip).Content } Running this function will return your external IP, and no other useless information. Source and examples : ...


2

This is a good usecase for awk. nslookup myip.opendns.com resolver1.opendns.com | awk -F': ' 'NR==6 { print $2 } ' Here we are piping to awk, delimiting by ": " and then only outputting the second delimited field of line 6.


9

batch, unfortunately, doesn't have a builtin getops function like bash does. However, you could implement your own poor-man's variant: :GETOPTS if /I %~1 == --age set AGE=%2& shift if /I %~1 == --gender set GENDER=%2& shift shift if not (%1)==() goto GETOPTS


8

Can you do it with Powershell? or does it need to be batch? Powershell makes it nice and easy, you just need to add something like this at the top of your script, and then you can call each parameter in any order param ( [string]$Age, [string]$Gender ) You can do it with batch, but it will require lots of parameter checking.. Here's a few links of some ...


1

You can use wget or curl for this. Both are command line tools to get web pages and have options to examine the return codes. For example: webmarc@plato:~$ wget http://www.google.com/ -S -O /dev/null 2>&1 | grep HTTP\/ HTTP/1.1 200 OK Here -S tells wget to print the server headers, -O saves the resultant file to /dev/null because I'm not ...


0

Here is a zsh-only variant, getting rid of ls as well as shuf: mplayer *.mp3(oe:REPLY=\$RANDOM:) The Glob Qualifier o executes (e) the code between both colons (:). The code in turn assigns every file a pseudo-random number $RANDOM, resulting in an arbitrary order. To obscure the command a little more, but mainly to save key strokes, you can define a ...


1

You have to do it like all the answers up there , but EXACT use of xargs will be something like this: echo argument1 argument2 argument3 | xargs -l bash -c 'echo this is first:$0 second:$1 third:$2' | xargs so in your case will be: find . -iname "*.mov" -printf "%p %f\n" | xargs -l bash -c 'echo ffmpeg -i $0 -f flv $1' | xargs p.s. this answers ...


2

You don't need ls at all. Try mplayer "${(f)$(shuf -e *.mp3)}" The problem with ls is that it is often aliased to something like ls --color=always and in that case prints invisible characters which are not recognized properly by other programs (shuf in this example).


0

I think i finally figured out a method: ${(f)"$(ls | shuf)"} Breakdown: ls | shuf: Shuffle files/dirs as expected. "$(...)": The quotes maintain the output as it is, including newlines. ${(f)...}: Splits the result of the expansion at newlines yielding an array of the file/dir names. "${(f)$(ls | shuf)}" works as well, ${(f)$(ls | shuf)}, does not.


4

I've solved the problem with the bash ${var:+...} extension, (reference). The script now changes to curl \ ${title:+ --data-urlencode "title=${title}"} \ http://example.com which works perfectly. Also see: Bash - function with optional arguments and missing logic How to write a bash script that takes optional input arguments?



Top 50 recent answers are included