Execute the Output Lines.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute the Output Lines.
# 1  
Old 06-09-2009
Execute the Output Lines.

Hi, My Script looks like this

Code:
#! /bin/ksh
cd /usr/SrcFiles/ADD;
while read line
do
d=`echo $line|cut -d'.' -f1`
echo $d".XML" >> XML_File_List.txt
out=`echo "gunzip -c -S .ZIP $d.ZIP > $d.XML;"`
echo $out
per=`echo "chmod ugo+rwx $d.XML;"`
echo $per
done <ZIP_File_List.txt

and the output :

Code:
gunzip -c -S .ZIP DW_PDT_090607170009.ZIP > DW_PDT_090607170009.XML;
chmod ugo+rwx DW_PDT_090607170009.XML;
gunzip -c -S .ZIP DW_PDT_090608010008.ZIP > DW_PDT_090608010008.XML;
chmod ugo+rwx DW_PDT_090608010008.XML;
gunzip -c -S .ZIP DW_PDT_090608010019.ZIP > DW_PDT_090608010019.XML;
chmod ugo+rwx DW_PDT_090608010019.XML;
gunzip -c -S .ZIP DW_PDT_090608090015.ZIP > DW_PDT_090608090015.XML;
chmod ugo+rwx DW_PDT_090608090015.XML;

My problem is i want to execute the output lines.How can i do that Smilie. Any help appreciated Smilie

Last edited by Don Cragun; 06-06-2016 at 01:21 AM.. Reason: Change B tags to CODE tags and add CODE tags.
# 2  
Old 06-09-2009
save the output into a file and at the end of the script execute the same.

Code:
#! /bin/ksh
cd /usr/SrcFiles/ADD;
while read line
do
d=`echo $line|cut -d'.' -f1`
echo $d".XML" >> XML_File_List.txt
out=`echo "gunzip -c -S .ZIP $d.ZIP > $d.XML;"`
echo $out >> tempfile.sh
per=`echo "chmod ugo+rwx $d.XML;"`
echo $per >> tempfile.sh
done <ZIP_File_List.txt
chmod +x tempfile.sh 
./tempfile.sh

# 3  
Old 06-09-2009
Why don't you execute the commands within your script?

Code:
#! /bin/ksh

cd /usr/SrcFiles/ADD;
while read line
do
  d=`echo $line|cut -d'.' -f1`
  echo $d".XML" >> XML_File_List.txt
  gunzip -c -S .ZIP $d.ZIP > $d.XML
  chmod ugo+rwx $d.XM
done <ZIP_File_List.txt

# 4  
Old 06-09-2009
Quote:
Originally Posted by Franklin52
Why don't you execute the commands within your script?

Code:
#! /bin/ksh

cd /usr/SrcFiles/ADD;
while read line
do
  d=`echo $line|cut -d'.' -f1`
  echo $d".XML" >> XML_File_List.txt
  gunzip -c -S .ZIP $d.ZIP > $d.XML
  chmod ugo+rwx $d.XM
done <ZIP_File_List.txt

Dont know how to do it Smilie
# 5  
Old 06-09-2009
Quote:
Originally Posted by naveen.kuppili
Dont know how to do it Smilie
Just run the script as I mentioned above.Smilie

Regards
# 6  
Old 06-09-2009
Quote:
Originally Posted by Franklin52
Just run the script as I mentioned above.Smilie

Regards
It is not giving me the output.Smilie

-----Post Update-----

Quote:
Originally Posted by Franklin52
Just run the script as I mentioned above.Smilie

Regards
Sorry Smilie i changed just a line and its working. Thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute python file, FTP output to another server

Greetings all, We are implementing a new tool called URLwatch which is a python utility. Here are the requirements. 1) Run every 10 seconds 2) Execute the python script 3) Output file gets generated, FTP it to a differernt server I gave no idea how to do this and management needs a demo... (3 Replies)
Discussion started by: jeffs42885
3 Replies

2. Shell Programming and Scripting

How to execute standard output ?

Alright so i got this script genpipe: echo "$*" |sh genscript file vi file << 'HERE' :%s/^/echo /g :%s/ $//g :%s/ /&\| xargs \.\/plus /g :wq HERE cat file Which generates output like echo 1 | xargs ./plus 2 | xargs ./plus 3 and so on Now i got the next script multiplus, who should... (3 Replies)
Discussion started by: Bertieboy7
3 Replies

3. Shell Programming and Scripting

Execute output lines

I have a command (not shell script) that general several lines of output like this... scp /var/lib/mysql/jitu/email.* root@172.29.0.218:/root/pitu/ scp /var/lib/mysql/jitu/orders.* root@172.29.0.218:/root/pitu/ I tried adding xargs but it did not work. -exec was not tried because I guess it... (3 Replies)
Discussion started by: shantanuo
3 Replies

4. Shell Programming and Scripting

Execute command created from sql output

Hi, I've would like to create kill statement from sqlplus output. So, I've modified somoene's script : mud_kill_stmt=`sqlplus -s / as sysdba <<EOF select 'kill -9 ' || p.SPID || ';' statement from $process_view p, $session_ ......... and so on exit; EOF` $mud_kill_stmt | tr ... (1 Reply)
Discussion started by: Arkadiusz Masny
1 Replies

5. Shell Programming and Scripting

Compare lines and execute

Greetings, I'm new to scripting and need a little help. I have a NAS server and want to make a script that bans IP if they fail login several times. The problem is that I dont know how to compare the IP's in the file. If they exist more than 3 times do .... #!/bin/sh set -x X=4 rm... (2 Replies)
Discussion started by: ntenz
2 Replies

6. Shell Programming and Scripting

How to execute the rest of the code after commenting multiple lines?

Hi, As I have seen in this forum how to comment multiple lines in the script, but it does not work properly for me. It is blocking the code but it does not execute the rest of the codes. This is my code #! /usr/bin/ksh month='date +"m%"' : << Comments Block if || then echo "inc =... (12 Replies)
Discussion started by: Yamini Thoppen
12 Replies

7. Shell Programming and Scripting

Execute the Output

I am developing a shell script to dynamically generate the DMLs (for hundreds of SQL/Tables) using the gendml command. I want to pass the output of this program(gen_dml.ksh) to a shell and execute it. Can yo give some inputs? #!/bin/ksh #Program name :=gen_dml.ksh echo m_db gendml oracle.dbc... (2 Replies)
Discussion started by: kousikan
2 Replies

8. Shell Programming and Scripting

Execute the output of one liner print

Hello I wrote simple one liner that take RunTime *.exe and link them to the output of the compilation output: find ~/DevEnv/. -name "*.exe" | xargs ls -l | awk '{ x=split($9,a,"/"); print "ln -s " $9 " "a}' and it gives me the desire output , but how can I execute this ln command on every... (1 Reply)
Discussion started by: umen
1 Replies

9. UNIX for Dummies Questions & Answers

output and execute

hi, does this mean that the output will go to a file named $3 with an x in the end, and then it will be executed? grep $1 filename > $3x chmod a+x $3x $3x thanks (2 Replies)
Discussion started by: gammaman
2 Replies

10. Shell Programming and Scripting

How can I get an if statement to execute based on number of lines in a file?

I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for: $ ps -ef | grep wtrs --- webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies
Login or Register to Ask a Question