Script that takes in variables, and outputs to another text or script file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that takes in variables, and outputs to another text or script file
# 1  
Old 05-19-2009
Script that takes in variables, and outputs to another text or script file

Ok, I sort of need to create a command files that will be ftped to another server to run.

I have some input variable that will need to be read, and then transformed into another script file. Here are some examples.

Server 1:
outputCmd.sh

passing in ./outputCmd.sh nh8oaxt Release_4_0 dwbe dev
----------------------------------------------------------
#!/bin/bash
uname = $1
tgt-directory = $2
app = $3
env = $4

execcmd = "exec prog emxSpinnerAgent.tcl "
echo "set context user" $uname "pass "$uname"; > runExecCmd.sh
echo "push context user creator"; > runExecCmd.sh

echo "execcmd "/spinner/$app"/"env"/"$tgt-directory"; > runExecCmd.sh
~
----------------------------------------------------------
Server 1:
runExecCmd.sh

This is what the command file should look like when it it finished.
----------------------------------------------------------
set context user nh8oaxt pass nh8oaxt;
push context user creator;

exec prog emxSpinnerAgent.tcl "/spinner/dwbe/dev/Release_4_0";
----------------------------------------------------------

I will take this runExecCmd.sh file, and ftp it to Server 2.

Thanks for any help.
# 2  
Old 05-19-2009
Actually I figured it out myself.

Here is what I have:


#!/bin/ksh
echo $1 $2 $3 $4
user=$1
app=$2
env=$3
release=$4

echo "set context user $user pass $user;" > runCmdFile.txt
echo "push context user creator;" >> runCmdFile.txt
echo "exec prog emxSpinnerAgent.tcl \"/spinner/$app/$env/$release\";" >> runCmdFile.txt


orozcom




Quote:
Originally Posted by orozcom
Ok, I sort of need to create a command files that will be ftped to another server to run.

I have some input variable that will need to be read, and then transformed into another script file. Here are some examples.

Server 1:
outputCmd.sh

passing in ./outputCmd.sh nh8oaxt Release_4_0 dwbe dev
----------------------------------------------------------
#!/bin/bash
uname = $1
tgt-directory = $2
app = $3
env = $4

execcmd = "exec prog emxSpinnerAgent.tcl "
echo "set context user" $uname "pass "$uname"; > runExecCmd.sh
echo "push context user creator"; > runExecCmd.sh

echo "execcmd "/spinner/$app"/"env"/"$tgt-directory"; > runExecCmd.sh
~
----------------------------------------------------------
Server 1:
runExecCmd.sh

This is what the command file should look like when it it finished.
----------------------------------------------------------
set context user nh8oaxt pass nh8oaxt;
push context user creator;

exec prog emxSpinnerAgent.tcl "/spinner/dwbe/dev/Release_4_0";
----------------------------------------------------------

I will take this runExecCmd.sh file, and ftp it to Server 2.

Thanks for any help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read variables from a text file for use in csh script

Hello, I have a text file (say, declarevars.txt) that contains multiple lines that are essentially meant to be variable declarations: set arr1 = (var1a var1b var1c) set arr2 = (var2a var2b var2c) . . . I want to be able to read this text file within a csh (sorry) script and have that... (2 Replies)
Discussion started by: arjaydj
2 Replies

2. UNIX for Dummies Questions & Answers

Pass variables from a text file to a shell script

Hi, I have a text file as follows: a.txt ------ STEPS=3 STEP_DURATION=100 INTERVAL=60 I want to use these values in a shell script. How to go about this? (3 Replies)
Discussion started by: akarnya
3 Replies

3. Shell Programming and Scripting

Read record from the text file & assign those values to variables in the script

For eg: I have sample.txt file with 4 rows of record like: user1|password1 user2|password2 user3|password3 user4|password4 The username and password is sepsrated by '|' I want to get the 1st row value from the file and assign it to two different variables(username and password) in my... (1 Reply)
Discussion started by: priya001
1 Replies

4. Shell Programming and Scripting

Need help to run sql query from a script..which takes input from a file

I need to run sql script from shell script which takes the input from a file and contents of file will be like : 12345 34567 78657 and query will be like : select seq_nbr from bus_event where event_nbr='12345'; select seq_nbr from bus_event where event_nbr='34567'; select seq_nbr... (1 Reply)
Discussion started by: rkrish
1 Replies

5. Shell Programming and Scripting

Storing outputs into variables

I need to know how to store output from one command so that it can initiate another command. chktraf -s | cut -c1-4 output would look like 321 142 256 342 123 Then if the value of the output = 0, then initiate next command. if then for xx in 01 02 03 04 05 06 07 08 09 10 do ... (4 Replies)
Discussion started by: Shaun74
4 Replies

6. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

7. Shell Programming and Scripting

need inputs on how i can change my script to reduce amount of time the script takes

HI , I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the... (1 Reply)
Discussion started by: madhul2002
1 Replies

8. Shell Programming and Scripting

problems with a script that outputs data to a file

First of all, im a total newbie to the point that i do not know what are the terms to search for my problem. I did however spend the rest of the day today trying to figure out what is wrong with my bash script. ive always thought that the best way to learn is to tackle a problem heads on. but at... (1 Reply)
Discussion started by: joeribut
1 Replies

9. Shell Programming and Scripting

How to store the outputs of a shell script inside a log file???

My shell script file name is test.sh and the contents of this test.sh file are ps_file="package1.ps" echo $ps_file ps_file1=`echo $ps_file| sed "s/.ps//g"` echo $ps_file1 ps2pdf -dSAFER -sPAPERSIZE=a4 /tmp/A380_RFS24/amm_r0_ps/$ps_file1.ps /tmp/A380_RFS24/amm_r0_pdf/$ps_file1.pdf Now i... (2 Replies)
Discussion started by: sunitachoudhury
2 Replies

10. Shell Programming and Scripting

unix script to takes the old data from a TXT file and compress them into new file

Hi, I am looking for the unix script which can takes the 2 month old data from a TXT file (there is one txt file in whiche messages are appended on daily basis) and compress them into new file.Please halp me out. (2 Replies)
Discussion started by: vpandey
2 Replies
Login or Register to Ask a Question