Setting a variable in a stream of commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting a variable in a stream of commands
# 1  
Old 11-10-2015
Setting a variable in a stream of commands

can someone help me with this?

Code:
AgentDX=/tmp/tesfinal && cat final.enc | openssl aes-128-cbc -a -d -salt -k hello | sh


the content of final.enc is a code. and in that code, the value of AgentDX is needed. however, i cant seem to find a way to allow the code to recognize that the variable exist. any ideas?
# 2  
Old 11-10-2015
Code:
export AgentDX="/tmp/testfinal"

This User Gave Thanks to Aia For This Post:
# 3  
Old 11-10-2015
You're assumption is that final.enc can be run through a layer of evaluation.... so I'll stick with that assumption.... (and it's a big assumption!)

Code:
finalenc=`cat final.enc`
AgentDX=/tmp/tesfinal
eval echo "${finalenc}" | openssl aes-128-cbc -a -d -salt -k hello | sh

To avoid the evaluation, maybe a substitution would be better on the stream.
It would help (IMHO) if the AgentDX instead of being $AgentDX in final.enc , if instead it were ${AgentDX}. That's just a bit safer/easier on the parse.

then you could have:
Code:
AgentDX=/tmp/tesfinal
sed "s;\${AgentDX};${AgentDX};g" final.enc | openssl ... etc...

This User Gave Thanks to cjcox For This Post:
# 4  
Old 11-10-2015
Hmmm - I'm a bit confused - but, openssl seems to read from stdin, so how about
Code:
< final.enc AgentDX=/tmp/tesfinal openssl aes-128-cbc -a -d -salt -k hello | sh

This User Gave Thanks to RudiC For This Post:
# 5  
Old 11-10-2015
Quote:
Originally Posted by RudiC
Hmmm - I'm a bit confused - but, openssl seems to read from stdin, so how about
Code:
< final.enc AgentDX=/tmp/tesfinal openssl aes-128-cbc -a -d -salt -k hello | sh

Perhaps I'm not understanding the OP, but I think the AgentDX the OP wants substituted is inside of the final.enc file, which is why you'd either need to force a round of eval on the content or use something else to substitute the desired value.
This User Gave Thanks to cjcox For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problems setting or exporting variable when using multiple commands from same line.

I am experimenting with some scripting as a way to learn more about it. I have a simple script that calls two other scripts. Each script echos some stuff to prove it ran and then sets a simple variable and exports it. I cannot get one of the variables to display back in the main calling script... (2 Replies)
Discussion started by: scottrif
2 Replies

2. HP-UX

Setting printer paper length using unix commands

Hi Guys, I have been trying to resolve a printing problem but nothing works out . I have an Epson LQ 680 (dot matrix printer) . I need to print a file . The paper length should be 34 .Left margin should be 5. I have tried the following things after researching from the man pages. pr -t... (24 Replies)
Discussion started by: Kar1234
24 Replies

3. Shell Programming and Scripting

[Video stream] network stream recording with mplayer

Hi I used this command: mplayer http://host/axis-cgi/mjpg/video.cgi -user root -passwd root \ -cache 1024 -fps 25.0 -nosound -vc ffh264 \ -demuxer 3 -dumpstream -dumpfile output.avi It's ok but... Video Playing is very fast! Why? Is it a synch problem? What parameter I have to use for... (1 Reply)
Discussion started by: takeo.kikuta
1 Replies

4. UNIX for Dummies Questions & Answers

Interpreting java output stream as system commands in Solaris

Hi there again, Running Solaris 10 with built-in Java. Seems to compile and run fine. Problem is: Say I want to see contents of current directory. In a shell, I'd just write "ls" and it outputs the content. When I write a Java file, I have the following line: System.out.println("ls"); ... (1 Reply)
Discussion started by: EugeneG
1 Replies

5. UNIX for Dummies Questions & Answers

setting a variable

In my script, I have the following command.... du -sk `ls -ltd sales12|awk '{print $11}'`|awk '{print $1}' it returns the value 383283 I want to modify my script to capture that value into a variable. So, I try doing the following... var1=`du -sk `ls -ltd sales12|awk '{print... (5 Replies)
Discussion started by: tumblez
5 Replies

6. Shell Programming and Scripting

Setting variable

How do you set a varible with information that contains a string and also another variable? For example: subject="Attention: $name / This $type needs your attention" The $xxxx are of course other variables that I instantiated earlier. Is it like Java where you have to use double quotes and... (1 Reply)
Discussion started by: briskbaby
1 Replies

7. Shell Programming and Scripting

Variable setting help please

L=0 cat test.sh | while read line do L='expr $1 + 1' echo $L done echo $l >>> the echo $L at the end produces 0 but i actually want it to produce the number of lines - any idea why this is happening? (16 Replies)
Discussion started by: penfold
16 Replies

8. UNIX for Dummies Questions & Answers

Setting a variable

I want to set a variable to be any number of dashes. Rather than doing the following: MYVAR="------------------" I'd like to be able to set the variable to, say, 80 dashes but don't want to have to count 80 dashes. Is there a way to do this? (2 Replies)
Discussion started by: photh
2 Replies

9. Programming

setting CC variable

I am trying to install GCC-3.1.1 on an SGI Indigo2. I already have MIPSpro 7.2.1 installed. However, when I try to configure GCC-3.1.1, I get the message "cc ERROR: cc -o conftest -g failed, You must set the environment variable CC to a working compiler." What is the name of the MIPSpro c++... (1 Reply)
Discussion started by: mdbanas
1 Replies
Login or Register to Ask a Question