Skip to content

Commit

Permalink
Added -no-log-timestamp option
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Jun 13, 2020
1 parent 4a8c022 commit 1b8f66c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 68 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,29 @@ Usage

shell2http [options] /path "shell command" /path2 "shell command2" ...
options:
-host="host" : host IP for http server (default bind to all interfaces)
-port=NNNN : port for http server, 0 - to receive a random port (default 8080)
-form : parse query into environment vars, handle uploaded files
-cgi : run scripts in CGI-mode:
- set environment variables with HTTP-request information
- write POST|PUT|PATCH-data to script STDIN (if is not set -form)
- parse headers from script (eg: "Location: URL\n\n")
-export-vars=var: export environment vars ("VAR1,VAR2,...")
by default export PATH, HOME, LANG, USER, TMPDIR
-export-all-vars: export all current environment vars
-no-index : don't generate index page
-add-exit : add /exit command
-log=filename : log filename, default - STDOUT
-shell="shell" : shell for execute command, "" - without shell (default "sh")
-cache=N : caching command out for N seconds
-one-thread : run each shell command in one thread
-show-errors : show the standard output even if the command exits with a non-zero exit code
-include-stderr : include stderr to output (default is stdout only)
-cert=cert.pem : SSL certificate path (if specified -cert/-key options - run https server)
-key=key.pem : SSL private key path
-basic-auth="" : setup HTTP Basic Authentication ("user_name:password")
-timeout=N : set timeout for execute shell command (in seconds)
-host="host" : host IP for http server (default bind to all interfaces)
-port=NNNN : port for http server, 0 - to receive a random port (default 8080)
-form : parse query into environment vars, handle uploaded files
-cgi : run scripts in CGI-mode:
- set environment variables with HTTP-request information
- write POST|PUT|PATCH-data to script STDIN (if is not set -form)
- parse headers from script (eg: "Location: URL\n\n")
-export-vars=var : export environment vars ("VAR1,VAR2,...")
by default export PATH, HOME, LANG, USER, TMPDIR
-export-all-vars : export all current environment vars
-no-index : don't generate index page
-add-exit : add /exit command
-log=filename : log filename, default - STDOUT
-shell="shell" : shell for execute command, "" - without shell (default "sh")
-cache=N : caching command out for N seconds
-one-thread : run each shell command in one thread
-show-errors : show the standard output even if the command exits with a non-zero exit code
-include-stderr : include stderr to output (default is stdout only)
-cert=cert.pem : SSL certificate path (if specified -cert/-key options - run https server)
-key=key.pem : SSL private key path
-basic-auth="" : setup HTTP Basic Authentication ("user_name:password")
-timeout=N : set timeout for execute shell command (in seconds)
-no-log-timestamp : log output without timestamps
-version
-help

Expand Down
43 changes: 22 additions & 21 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,28 @@ MacOS install:
Usage:
shell2http [options] /path "shell command" /path2 "shell command2" ...
options:
-host="host" : host for http server, default - all interfaces
-port=NNNN : port for http server, 0 - to receive a random port, default - 8080
-form : parse query into environment vars, handle uploaded files
-cgi : run scripts in CGI-mode:
- set environment variables with HTTP-request information
- write POST|PUT|PATCH-data to script STDIN (if not set -form)
- parse headers from script (eg: "Location: URL\n\n")
-export-vars=var: export environment vars ("VAR1,VAR2,...")
-export-all-vars: export all current environment vars
-no-index : don't generate index page
-add-exit : add /exit command
-log=filename : log filename, default - STDOUT
-shell="shell" : shell for execute command, "" - without shell
-cache=N : caching command out for N seconds
-one-thread : run each shell command in one thread
-show-errors : show the standard output even if the command exits with a non-zero exit code
-include-stderr : include stderr to output (default is stdout only)
-cert=cert.pem : SSL certificate path (if specified -cert/-key options - run https server)
-key=key.pem : SSL private key path
-basic-auth="" : setup HTTP Basic Authentication ("user_name:password")
-timeout=N : set timeout for execute shell command (in seconds)
-host="host" : host for http server, default - all interfaces
-port=NNNN : port for http server, 0 - to receive a random port, default - 8080
-form : parse query into environment vars, handle uploaded files
-cgi : run scripts in CGI-mode:
- set environment variables with HTTP-request information
- write POST|PUT|PATCH-data to script STDIN (if not set -form)
- parse headers from script (eg: "Location: URL\n\n")
-export-vars=var : export environment vars ("VAR1,VAR2,...")
-export-all-vars : export all current environment vars
-no-index : don't generate index page
-add-exit : add /exit command
-log=filename : log filename, default - STDOUT
-shell="shell" : shell for execute command, "" - without shell
-cache=N : caching command out for N seconds
-one-thread : run each shell command in one thread
-show-errors : show the standard output even if the command exits with a non-zero exit code
-include-stderr : include stderr to output (default is stdout only)
-cert=cert.pem : SSL certificate path (if specified -cert/-key options - run https server)
-key=key.pem : SSL private key path
-basic-auth="" : setup HTTP Basic Authentication ("user_name:password")
-timeout=N : set timeout for execute shell command (in seconds)
-no-log-timestamp : log output without timestamps
-version
-help
Expand Down
47 changes: 24 additions & 23 deletions shell2http.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "SHELL2HTTP" "" "March 2020" "" ""
.TH "SHELL2HTTP" "" "June 2020" "" ""
HTTP\-server to execute shell commands\. Designed for development, prototyping or remote control\. Settings through two command line arguments, path and shell command\. By default bind to :8080\.
.
.SH "Usage"
Expand All @@ -10,28 +10,29 @@ HTTP\-server to execute shell commands\. Designed for development, prototyping o

shell2http [options] /path "shell command" /path2 "shell command2" \.\.\.
options:
\-host="host" : host IP for http server (default bind to all interfaces)
\-port=NNNN : port for http server, 0 \- to receive a random port (default 8080)
\-form : parse query into environment vars, handle uploaded files
\-cgi : run scripts in CGI\-mode:
\- set environment variables with HTTP\-request information
\- write POST|PUT|PATCH\-data to script STDIN (if is not set \-form)
\- parse headers from script (eg: "Location: URL\en\en")
\-export\-vars=var: export environment vars ("VAR1,VAR2,\.\.\.")
by default export PATH, HOME, LANG, USER, TMPDIR
\-export\-all\-vars: export all current environment vars
\-no\-index : don\'t generate index page
\-add\-exit : add /exit command
\-log=filename : log filename, default \- STDOUT
\-shell="shell" : shell for execute command, "" \- without shell (default "sh")
\-cache=N : caching command out for N seconds
\-one\-thread : run each shell command in one thread
\-show\-errors : show the standard output even if the command exits with a non\-zero exit code
\-include\-stderr : include stderr to output (default is stdout only)
\-cert=cert\.pem : SSL certificate path (if specified \-cert/\-key options \- run https server)
\-key=key\.pem : SSL private key path
\-basic\-auth="" : setup HTTP Basic Authentication ("user_name:password")
\-timeout=N : set timeout for execute shell command (in seconds)
\-host="host" : host IP for http server (default bind to all interfaces)
\-port=NNNN : port for http server, 0 \- to receive a random port (default 8080)
\-form : parse query into environment vars, handle uploaded files
\-cgi : run scripts in CGI\-mode:
\- set environment variables with HTTP\-request information
\- write POST|PUT|PATCH\-data to script STDIN (if is not set \-form)
\- parse headers from script (eg: "Location: URL\en\en")
\-export\-vars=var : export environment vars ("VAR1,VAR2,\.\.\.")
by default export PATH, HOME, LANG, USER, TMPDIR
\-export\-all\-vars : export all current environment vars
\-no\-index : don\'t generate index page
\-add\-exit : add /exit command
\-log=filename : log filename, default \- STDOUT
\-shell="shell" : shell for execute command, "" \- without shell (default "sh")
\-cache=N : caching command out for N seconds
\-one\-thread : run each shell command in one thread
\-show\-errors : show the standard output even if the command exits with a non\-zero exit code
\-include\-stderr : include stderr to output (default is stdout only)
\-cert=cert\.pem : SSL certificate path (if specified \-cert/\-key options \- run https server)
\-key=key\.pem : SSL private key path
\-basic\-auth="" : setup HTTP Basic Authentication ("user_name:password")
\-timeout=N : set timeout for execute shell command (in seconds)
\-no\-log\-timestamp : log output without timestamps
\-version
\-help
.
Expand Down
10 changes: 8 additions & 2 deletions shell2http.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ func (cnf Config) readableURL(addr fmt.Stringer) string {
// getConfig - parse arguments
func getConfig() (cmdHandlers []Command, appConfig Config, err error) {
var (
logFilename string
basicAuth string
logFilename string
basicAuth string
noLogTimestamp bool
)

switch runtime.GOOS {
Expand All @@ -155,6 +156,7 @@ func getConfig() (cmdHandlers []Command, appConfig Config, err error) {
}

flag.StringVar(&logFilename, "log", "", "log filename, default - STDOUT")
flag.BoolVar(&noLogTimestamp, "no-log-timestamp", false, "log output without timestamps")
flag.IntVar(&appConfig.port, "port", PORT, "port for http server")
flag.StringVar(&appConfig.host, "host", "", "host for http server")
flag.BoolVar(&appConfig.setCGI, "cgi", false, "run scripts in CGI-mode")
Expand Down Expand Up @@ -196,6 +198,10 @@ func getConfig() (cmdHandlers []Command, appConfig Config, err error) {
log.SetOutput(fhLog)
}

if noLogTimestamp {
log.SetFlags(0)
}

if len(appConfig.cert) > 0 && len(appConfig.key) == 0 ||
len(appConfig.cert) == 0 && len(appConfig.key) > 0 {
return nil, Config{}, fmt.Errorf("requires both -cert and -key options")
Expand Down

0 comments on commit 1b8f66c

Please sign in to comment.