printf/echo in a second script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printf/echo in a second script
# 1  
Old 04-14-2011
printf/echo in a second script

This may be little confusing. I have Script1, which pulls data from the system and creates another script(lets say script2). While I run script1 I need to add printf/echo statements for script2, so that when I run script2 I see those statement.
eg: script1 765
Code:
printf " display frame-$1 timeoffset " >> script2

script2
Code:
display  frame-765 timeoffset
printf " Enter the time offset "  # this is printf /echo statement I want to add in script1
read time

I thought it would be something like this.
on script1
Code:
printf " display frame-$1 timeoffset " >> script2
printf " printf "Enter the time offset " "  # this is the one I have problem with
printf " read time"


Last edited by Franklin52; 04-14-2011 at 09:49 AM.. Reason: Please use code tags
# 2  
Old 04-14-2011
This worked for me:
Code:
cat script1
printf ' echo "display frame-$1 timeoffset " ' >> script2
printf "\n" >> script2
printf ' echo "Enter the time offset " ' >> script2
printf "\n" >> script2
printf 'read time' >> script2
chmod +x script2

# 3  
Old 04-14-2011
thanks It worked...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Availability: echo vs. printf?

Hello, For some reason i dont remember, i currently believe (but beeing unsure) that printf is available on more diffrent systems (unix, bsd, linux, ??) than echo is. Could someone please enlighten me, whether this is true or not? Thank you PS: I just found pages about the diffrences of... (3 Replies)
Discussion started by: sea
3 Replies

2. Shell Programming and Scripting

Grep behaves diffrent upon printf or echo output

Hello I want to check whether certain arguments were passed to the script, and when those are, not doing a log entry. If those arguments are not passed, always do a log entry (*new call*). What currently i have is this: echo "${@}"|grep -q \\- || \ tui-log -e "$LOG" "\r---- New call $$... (4 Replies)
Discussion started by: sea
4 Replies

3. Shell Programming and Scripting

Managing output... echo or printf?

Hello script guru's as i write more and more code i always block at managing output... either writing to standard out, writing to files via std out (log, temp file, etc). Don't get me wrong 99% of the time it DOES the job but maybe there is more efficient. I'm writing a small script to... (2 Replies)
Discussion started by: maverick72
2 Replies

4. UNIX for Dummies Questions & Answers

Meaning of script with echo, -d, -f1, -f2

Hello Friends, I am a new learner of Unix & need to understand below script as start up, Can anyone explain the meaning of each line listed below. Thanks for your time. #!/usr/bin/ksh PARAMS=$1 #echo "parms passed is $PARAMS @" STATUS=`echo ${PARAMS} | cut -d: -f1` JOBNAME=`echo... (9 Replies)
Discussion started by: DK2014
9 Replies

5. Shell Programming and Scripting

Need help in printf in shell script

My requirement is need to add spaces to the string with the dynamic value to printf... this is a part of shell script ..which i have , the length is not static ... length=15 value="1234567890" printf "%-"$length"s\n" "$value"; The result it is printing is ... i am not sure y it is... (19 Replies)
Discussion started by: greenworld123
19 Replies

6. Shell Programming and Scripting

\n in ksh using echo & printf

#!/usr/bin/ksh var1="Hi World" var2="Morning" var3=$(echo "$var1" \n "$var2") echo $var3 var3=$(printf "$var1 \n $var2") echo $var3 Output Any way to get in my $var3 ? (7 Replies)
Discussion started by: dahlia84
7 Replies

7. Shell Programming and Scripting

problem with printf in shell script

i have written small script as follows: name="hi hello" printf "%-20s" $name This gives me strange output. -20s format is applied on both word of string. i.e it displays both word hi and hello in space of 20 length. I want to display entire string "hi hello" in length of 20 space. plz... (2 Replies)
Discussion started by: admc123
2 Replies

8. Shell Programming and Scripting

trying to create printf script

I am trying to make a script that randomly generates 4 sets of numbers with decimal points. Then it outputs that to a variable and a file. This is what I have: #!/bin/bash printf -v RANDOM_2 "%s\n" "$RANDOM"."$RANDOM" "$RANDOM"."$RANDOM" "$RANDOM"."$RANDOM" "$RANDOM"."$RANDOM" printf... (3 Replies)
Discussion started by: pkohn11
3 Replies

9. Shell Programming and Scripting

advanced echo/printf

I want to print a colored line using bash. I want to print: Smtp status where "Smtp status" will be in yellow and will be in green. Thanks. (2 Replies)
Discussion started by: proactiveaditya
2 Replies

10. Shell Programming and Scripting

Using echo to create a script

Hello all, I want to be able to create a script on the fly from another script by echoing lines into a file, but am running into difficulty, as it isn't working right. What am I doing wrong? echo "for i in `grep $FRAME /root_home/powermt.sort.fil |awk '{print $7}'`" > pvtimout_set.sh... (5 Replies)
Discussion started by: LinuxRacr
5 Replies
Login or Register to Ask a Question