URL Functions
urlParse
Simple URL Parsing
Usage
urlParse [ --help ] [ url ] [ --prefix prefix ] [ --uppercase ]
Simple URL parsing. Converts a url into values which can be parsed or evaluated:
url- URLhost- Hostuser- Userpassword- Passwordport- Connection portname- Path with the first slash removedpath- Path
Does little to no validation of any characters so best used for well-formed input.
Now works on multiple URLs, output is separated by a blank line for new entries
Return Code: 0 - If parsing succeeds Return Code: 1 - If parsing fails
Arguments
--help- Optional. Flag. Display this help.url- a Uniform Resource Locator--prefix prefix- String. Optional. Prefix variable names with this string.--uppercase- Flag. Optional. Output variable names in uppercase, not lowercase (the default).
Examples
eval "$(urlParse scheme://user:password@host:port/path)"
echo $name
Return codes
0- Success1- Environment error2- Argument error
urlParseItem
Get a URL component directly
Usage
urlParseItem component url0 [ url1 ... ]
Extract a component from one or more URLs
Arguments
component- the url component to get:url,path,name,scheme,user,password,host,port,portDefault,errorurl ...- String. URL. Required. A Uniform Resource Locator used to specify a database connection
Examples
decorate info "Connecting as $(urlParseItem user "$url")"
Return codes
0- Success1- Environment error2- Argument error
urlSchemeDefaultPort
Output the port for the given scheme
Usage
urlSchemeDefaultPort [ --help ] [ --handler handler ] scheme ...
Output the port for the given scheme
Arguments
--help- Optional. Flag. Display this help.--handler handler- Optional. Function. Use this error handler instead of the default error handler.scheme ...- Required. String. Scheme to look up the default port used for that scheme.
Return codes
0- Success1- Environment error2- Argument error
urlValid
Checks if a URL is valid
Usage
urlValid [ --help ] url ...
Checks if a URL is valid Return Code: 0 - all URLs passed in are valid Return Code: 1 - at least one URL passed in is not a valid URL
Arguments
--help- Optional. Flag. Display this help.url ...- String. URL. Required. A Uniform Resource Locator
Return codes
0- Success1- Environment error2- Argument error
urlOpen
Open a URL using the operating system
Usage
urlOpen [ --help ] [ --ignore ] [ --wait ] [ --url url ]
Open a URL using the operating system Usage urlOpen [ --help ]
Reads standard input
line:URL
Writes to standard output
none
Arguments
--help- Optional. Flag. Display this help.--ignore- Optional. Flag. Ignore any invalid URLs found.--wait- Optional. Flag. Display this help.--url url- Optional. URL. URL to download.
Return codes
0- Success1- Environment error2- Argument error
urlOpener
Open URLs which appear in a stream
Usage
urlOpener [ --exec ]
Open URLs which appear in a stream (but continue to output the stream)
Reads standard input
text
Writes to standard output
text
Arguments
--exec- Executable. Optional. If not supplied usesurlOpen.
Return codes
0- Success1- Environment error2- Argument error
urlFilter
Open URLs which appear in a stream
Usage
urlFilter [ file ]
urlFilter [ --show-file ] [ --file name ] [ file ]
Open URLs which appear in a stream
Takes a text file and outputs any https:// or http:// URLs found within.
URLs are explicitly trimmed at quote, whitespace and escape boundaries.
Reads standard input
text
Writes to standard output
line:URL
Arguments
--show-file- Boolean. Optional. Show the file name in the output (suffix with:)--file name - String. Optional. The file name to display- can be any text.file- File. Optional. A file to read and output URLs found.
Return codes
0- Success1- Environment error2- Argument error
urlFetch
Fetch URL content
Usage
urlFetch [ --help ] [ --header header ] [ --wget ] [ --redirect-max maxRedirections ] [ --curl ] [ --binary binaryName ] [ --argument-format format ] [ --user userName ] [ --password password ] url [ file ]
Fetch URL content
Arguments
--help- Optional. Flag. Display this help.--header header- String. Optional. Send a header in the format 'Name: Value'--wget- Flag. Optional. Force use of wget. If unavailable, fail.--redirect-max maxRedirections- PositiveInteger. Optional. Sets the number of allowed redirects from the original URL. Default is 9.--curl- Flag. Optional. Force use of curl. If unavailable, fail.--binary binaryName- Callable. Use this binary instead. If the base name of the file is notcurlorwgetyou MUST supply--argument-format.--argument-format format- Optional. String. Supplycurlorwgetfor parameter formatting.--user userName- Optional. String. If supplied, uses HTTP Simple authentication. Usually used with--password. Note: User names may not contain the character:when usingcurl.--password password- Optional. String. If supplied along with--user, uses HTTP Simple authentication.url- Required. URL. URL to fetch to target file.file- Optional. FileDirectory. Target file. Use-to send tostdout. Default value is-.
Return codes
0- Success1- Environment error2- Argument error
Requires
returnMessage whichExists printf decorate usageArgumentString throwArgument catchArgument throwEnvironment catchEnvironment