BTEQ interactive window, need arrow-up to access command history - putty

This is strange. New linux environment, accessed from my desktop via putty...
In my regular shell, I can up and down arrow to get command history. However, when I fire up BTEQ to talk to the database, I get this kind of gibberish in response to my up/down/ctrl+up/etc.
BTEQ -- Enter your SQL request or BTEQ command:
^[OA^[OB^[[A^[[B^[OA^[OA^[[D
Is this something in BTEQ? I would assume more of a setting in putty or "stty" type of command in my .profile. However, since the behavior is normal until I launch BTEQ I can't be sure.

BTEQ does not maintain a command history like the shell in your LINUX/UNIX environment. Therefore, using the up/down/ctl+up keys will be interpreted as input and not interpreted by the shell to navigate a command history.

Related

How to "pipe" console values into interactive Windows PowerShell command (to make it non-interactive)

Does Windows PowerShell have anything that's similar to piping user-supplied values into interactive Unix/Linux bash commands to make them run non-interactive?
What I mean is something like this:
https://www.igorkromin.net/index.php/2017/04/12/invoking-interactive-shell-scripts-non-interactively
I need to supply values directly via PowerShell instead of letting the user type them on the console.
What I mean is not something that would be equivalent to xargs in bash, as that would only allow me to supplant command line parameters. For the specific command that I have in mind, default values can be specified on the command line, but are not suitable for the specific task. There are not any other parameters that can be given on the command line - values other than default are normally given by user input.
The only thing I tried out was similar to how you would do it in bash:
echo VALUE | CMD
This didn't work as the command still asked for user input on the console.

Why is my shell history not written sometimes, and how can I fix this?

Sometimes my shell history isn't written. I think it might be when a shell exits because of certain signals, like when the OS is shutting down. So:
is it true that bash and/or zsh don't write out their history when terminating as a response to certain signals?
is there a way to hook into these signals and tell the shell to still write history?
I would rather not have it write history after each command.
Your history command store in RAM until you regularly terminate your terminal. Then list of your command write into the .bash_history.
If you wanted to write your commands history at anytime you need, use below command:
#history -a
Based on history command manual -a append history lines from this session to the history file

How to extract information from a command prompt using shell script?

I need a shell script using which I can fetch data from command prompt. I need to fetch data from the command prompt of a router. When I write commands in a shell script it goes the prompt but not executing the next command. So running the script just stuck in the prompt. Bellow is my script file
#!/bin/sh
ccli
rsc
where ccli is the command to enter the prompt and rsc is the command to fetch some infomation.
So please suggest some method.
If ccli reads commands from stdin (which I don't know), you might get further with
printf 'rsc\n' | ccli
For more complicated tasks I suggest you look into expect which was invented for the sole reason of driving interactive programs in a scripted way.

How to execute a script in zsh and then become interactive?

I want to run a predetermined set of commands after the invocation of zsh (i.e. after .zshrc is executed) that returns the user to an interactive shell when complete.
Things like this comes to my mind:
urxvt -e 'zsh -c ". scriptname"'
but instead of exiting zsh and the terminal once the script finishes, I want an interactive shell at the end. The idea is to simply save users from having to type ". scriptname" whenever they log in.
Application: Several users are using the same account (strange but true) and I want to help in adjusting user specific settings. Yes, I know that one could use different accounts for that :-)
Not really what you were asking for, but should have the desired result. You use an environment variable to pass the name of the user-specific script to source to .zshrc (or other appropriate startup file).
urxvt -e 'USERSCRIPT=scriptname zsh'
Then in .zshrc for the actual user, include
. $USERSCRIPT
(All of this is not to say that there isn't an option to run a command then remain in interactive mode; I just can't find a way to do it, so I offer this workaround.)

Escape sequence <ESC>]0;

I am currently trying to write a script that uses expect to logon to SSH. Logging on to a server every prompt appears as [user#host]~/directory$ when I use a xterm color terminal. However, if I read the output from SSH directly with expect I see the following <ESC>]0;user#host:~/directory[user#host]~/directory$. Using export PS1="#-->" changes the result to <ESC>]0;user#host:~/directory#-->.
My question is: What does the sequence <ESC>]0;do? And which class of terminals does it belong to? I could not find it for neither VT52 nor VT100.
by default, the label of each tab is the name of the job that's running in that session. some systems are configured to augment this with additional information such as the hostname you're logged in to or your current directory; this is done by sending a special code of:
ESC]0;<string>^G
such as, ESC]0;david#Scott:~^G, would put "david#Scott:~" in my tab title
this is referred to as the XTERM hardstatus hack.

Resources