I totally dislike asking questions in forums but this one eats up to much of my time I need to spend on other topics.
I have a shell-script in which I call a terminal.
I want to invoke bash inside the terminal and print a message inside bash with aid of a here document.
See yourself.
works just fine and opens up a terminal with bash inside. But if I try to pass a command to bash itself the script fails.
I don't get it working.
A much nicer approach would be if I can pass a function (declared and defined) to bash?
I suppose the problem is, that bash is running in the context of the subshell of the terminal but my imagination and knowledge ends there.
I am almost sure that piping the result of a function in such a nested scenario is impossible.
Here documents require that EOF is at the start of the on a separate line and that is the only text on the line, so using you code as an example, you would need something like this
Alternatively you could use a here-string
Passing a function is possible with bash through an export of the function, but can this easily become a security risk, so imho is best avoided.
For passing text to a sub process you can use a named pipe if you just want it to display the message,
or use bash 4's coproc functionality for a two-way pipe.
Last edited by Scrutinizer; 12-09-2017 at 07:09 AM..
---------- Post updated at 06:43 AM ---------- Previous update was at 06:25 AM ----------
I'd really like to avoid it but I guess I am simply going to put the message in a file. I hate it if things don't work out like I want it. .-)
If someone knows a one-line solution I'd really like to know it!
But it seems difficult as there are several subshells involved and bash supposedly has some security mechanisms in conflict with the task to solve.
I'm sorry things aren't working out the way you want. But I'm confused as to what exactly is going wrong. You say that:
works. You said that some unspecified command fails, but don't show us what command you used and you don't tell us how it failed. Without clearly seeing what you're trying to do and knowing how what you have tried fails, it is really hard to suggest alternatives that might work for you.
Please show us what command you are trying to get bash to run in the terminal window you are opening, tell us what output is being produced, and tell us what output you were hoping to produce.
I thought it was self-explaining and didn't need any further explanation what I am trying to accomplish with this quite easy to understand fragment of a script.
Well, I just tried to present a solution but the ******* code-tags don't like my strict browser settings I guess.
However, the man page of the terminals might help... helps..
However, I am a bit ****** off actually because of the whole java-stuff going on this server stealing my time. I asked for the delete of my account.
I am afraid I am no more interested in the post.
Sorry.
Greets
George
Last edited by Scott; 12-09-2017 at 05:42 PM..
Reason: Removed profanity
Oracle Linux 5.6, 64-bit
Given the following snippet
wrkvar=`sqlplus -s / as sysdba <<EOF
set echo off feedback off head off trimsp on
select count(*) from v\$parameter
where name in ('db_file_name_convert','log_file_name_convert')
and value is not null;
EOF`
echo wrkvar=$wrkvarProduces... (2 Replies)
I have the following code:
strfuture=abcdefghi
ver=${strfuture:${count}:1}
mj7777_ver=${ver} start_mj7777_iteration
let count=count+1
When it is executed I get bad substitution. The same if I use
ver=${strfuture:$count:1}
mj7777_ver=${ver}... (6 Replies)
Hi,
I almost always use back quotes in scripts to assigin output of a command to a variable.
eg: file=`basename a/b/c/d/file`
year_mon=`date +%Y%m`
But the same can be achieved like:
file=$(basename a/b/c/d/file)
year_mon=$(date +%Y%m)
I would like to know if there is... (3 Replies)
Hi,
I want to know if there's a cleaner way for assigning output of a unix command to a variable in C program .
Example : I execute dirname fname and want the output to be assigned to a variable dname . Is it possible .
I knew u can redirect the output to a file and then reread assigning... (5 Replies)
Hello Folks,
how to write a command on vi that allow to repeat last substitution command?
Here what I want to do :
1
2
3
1
2
3
1
2
3
:.,+2s/\n/ /And I obtain :
1 2 3
1
2
3
1 (5 Replies)
Hey, guys!
Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek:
So, I wanted to use a command statement similar to the following.
This is kinda taken... (2 Replies)
I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename?
#!/bin/bash
filename=`echo $0`
/usr/bin/sed '/#include/ {
i\
the filename is `$filename`
}' $1
exit 0 (8 Replies)
I'm trying to get this to work and I'm not really sure how to do it.
echo $x | awk '{print $NF}' MODIFIEDThe output I'm trying to get should look like:
dir1 MODIFIED
Where dir1 will be the result of:
$x |awk '{print $NF}'I'm sure there's something I'm supposed to put around that part... (3 Replies)
Hi,
What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution?
while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file
But,
while IFS='\n' read -r... (3 Replies)
"Is there any substituation of last command or script syntax which can be used as a user. As far I know the "last" command is being used to display information about previous logins. A member of adm group or the user adm can execute it only.
Thanks in advance for your usual help.
Ghazi (6 Replies)