Different behavior between bash shell and bash script for cmd
So I'm trying to pass certain json elements as env vars and use them later on in a script.
Sample json:
(part of the) script:
The problem I'm having is that Element2 is breaking the line when exporting but if I just run "echo $JSON | jq "{Element1,Element2,Element3} | to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]"" at the cmd line, it looks fine:
Actual output of script:
As can be seen, the export command inserts single quotes into the "Element2" and I'm not sure where they come from.
The second variable (Element2) only contains the first element in the string (Name,). The behavior makes sense since the line is broken but for the life in me I cannot understand how or why the export command inserts them.
Does anyone know of a way to mimic the up arrow/down arrow type bash behavior within a shell script?
Say I have a scripted menu, and would like to be able to up arrow to bring up the last X number of lines of user input?
Thanks to anybody with a suggestion. :) (0 Replies)
hi,
i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
The block below isn't a surprise:$ ls
file1 file2 file3
$ x=*
$ echo $x
file1 file2 file3
$ echo '$x'
$x
$ echo "$x"
*
$But I found this block a bit bewildering:$ echo $x'
>'
*
$I'm wondering why substitution wasn't performed on the $x, since it was unquoted (as far as I can tell).... (5 Replies)
Hi all
I am relatively new to linux (specifically red hat). I have installed Fedora 13 on my machine and started playing with the terminal when i found a very strange behavior when typing a command that is not found:
the terminal does not prompt me back. In other words, i am logged as root (or... (4 Replies)
run_xfs_fsr is a xfs filesystem maintenance script designed to run under cron. The system is a home theater personal computer running mythbuntu 10.10, and is accessed remotely for these tests. cron runs a script, (xfs_fsr.sh) at 02:30 that runs the subject script under BASH and sets the... (3 Replies)
I am trying to get my history in sync in multiple bash sections and things aren't working the way I expect.
Desired behavior, hitting esc-K in all bash sessions (same userid and machine) will use the same history.
Observed behavior: Esc-k shows the history of the current session, rather than... (8 Replies)
# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi
espeacailly the top regex part?
---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
Good Morning
I think there may be something I dont understand fully.
The following code works well, but I dont like the set domen method.
#!/bin/bash
#
domen="y"
while
do
echo " M A I N - M E N U"
echo "1. Contents of /etc/passwd"
echo "2. List of users currently logged"
echo... (10 Replies)
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ?
--- Post updated at 08:39 AM ---
in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies
LEARN ABOUT DEBIAN
json_write
json::write(3tcl) JSON json::write(3tcl)__________________________________________________________________________________________________________________________________________________NAME
json::write - JSON generation
SYNOPSIS
package require Tcl 8.5
package require json::write ?1.0.1?
::json::write indented
::json::write indented flag
::json::write aligned
::json::write aligned flag
::json::write string s
::json::write array arg...
::json::write object key value...
_________________________________________________________________DESCRIPTION
The json::write package provides a simple Tcl-only library for generation of text in the JSON http://www.json.org/ data exchange format as
specified in RFC 4627 http://www.ietf.org/rfc/rfc4627.txt.
COMMANDS
::json::write indented
This method returns the current state of the indentation setting.
::json::write indented flag
This and the method aligned configure the layout of the JSON generated by the package.
If this flag is set (default) the package will break the generated JSON code across lines and indent it according to its inner
structure, with each key of an object on a separate line.
If this flag is not set, the whole JSON object will be written on a single line, with minimum spacing between all elements.
::json::write aligned
This method returns the current state of the alignment setting.
::json::write aligned flag
This and the method indented configure the layout of the JSON generated by the package.
If this flag is set (default) the package ensures that the values for the keys in an object are vertically aligned with each other,
for a nice table effect. To make this work this also implies that indented is set as well.
If this flag is not set, the output is formatted as per the value of indented, without trying to align the values for object keys.
::json::write string s
This method takes the string s and returns it properly quoted for JSON as its result.
::json::write array arg...
This method takes a series of JSON formatted arguments and returns them as a properly formatted JSON array as its result.
::json::write object key value...
This method takes a series of key/value arguments, the values already formatted for JSON, and returns them as a properly formatted
JSON object as its result, with the keys formatted as JSON strings.
BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category json of
the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for
either package and/or documentation.
KEYWORDS
data exchange, exchange format, javascript, json
CATEGORY
CGI programming
COPYRIGHT
Copyright (c) 2009-2011 Andreas Kupries <andreas_kupries@sourceforge.net>
json 1.0.1 json::write(3tcl)