Sponsored Content
Top Forums Shell Programming and Scripting Problem with writing into a file through shell script Post 302524843 by joydeep4u on Tuesday 24th of May 2011 09:18:36 PM
Old 05-24-2011
Problem with writing into a file through shell script

Hi all,

I have a shell script which I use to login to the server from the client and then from the server I run a bunch of other scripts to complete my task. I am having problems with the script below-
Code:
#!/bin/bash

while read line
do
connections=`echo $line | cut -d " " -f 1`
period=`echo $line | cut -d " " -f 2`
testcaseid=`echo $line | cut -d " " -f 3`

ssh  192.168.1.202 <<EOF
sudo ./collectlcpu.sh $period $connections $testcaseid&
#sudo ./oprofile.sh $period $connections $testcaseid
sudo ./interrupt.sh $period $connections $testcaseid
#sleep 10
exit
EOF

./httperf1.sh $period $connections $testcaseid&
sleep 12

ssh  192.168.1.202  <<EOF
sudo killall collectl
sudo killall collectlcpu.sh
sudo killall interrupt.sh
sudo opcontrol --shutdown
sudo killall oprofile.sh
#killall pfmon.sh
#killall pfmon
exit
EOF
done  <  "/home/joydeep/input.txt"

sleep 30

The interrupt script is given below-
Code:
#!/bin/bash

dt=`date +%m%d%l%M`
dtstring=`echo $dt|sed 's/ //g'`

period=$1
connections=$2
testcaseid=$3
echo "STARTING THE INTERRUPT SCRIPT"
outputfile0="output_period_""Core2_""$period""_""connections""_""$connections""_""$testcaseid""_""$dtstring"".txt"
outputfile2="output_period_""Core0_""$period""_""connections""_""$connections""_""$testcaseid""_""$dtstring"".txt"
for i in 1 2 3 4 5 6 7 8 9 10 11 12
do
line1=`cat /proc/interrupts | grep eth3-TxRx-0`
line2=`cat /proc/interrupts | grep eth2-TxRx-0`
nohup echo $line1 >> /home/joydeep/results/interrupt/samesocket/data_cache_misses/"$outputfile0"&
nohup echo $line2 >> /home/joydeep/results/interrupt/samesocket/data_cache_misses/"$outputfile2"&
sleep 1
done
echo "END OF THE INTERRUPT SCRIPT"

The problem is that the script is not writing the files in /home/joydeep/results/interrupt.

Thanks,
Joydeep

Last edited by Franklin52; 05-25-2011 at 07:20 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

2. UNIX for Dummies Questions & Answers

HELP! writing shell script with c++ file

how would i write a shell script to count number of one-line comments in a c++ file. please help with coding thank you. (1 Reply)
Discussion started by: deadleg
1 Replies

3. Shell Programming and Scripting

Shell script for a writing the directory structure to a file

Hi All, I am new user of shell scripting has come up with a problem. that I have a directory structure like : Home | |--------A | |----trunk | |-------A_0_1/ | | | |-------A_0_2/ | |--------B | ... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

4. Shell Programming and Scripting

Script writing problem

Self professed idot looking for help LOL Hi all, I am new to Unix and I have to write a shell script that will check to see if a file exist and then create it if it does not. The file I need to search for is titled "A1. dat" and here is my feeble attempt at creating the script: #!/bin/bash... (2 Replies)
Discussion started by: Tinablue
2 Replies

5. Shell Programming and Scripting

Shell Script to remove spaces while writing to the file

Hello Folks, I want to get the results from a SQL query which needs to be exported to a .txt file. My Script is something like #!/bin/ksh db2 connect to DATABASE user user_name using pwd; touch test.txt isResult=0; isResult= `db2 -x select 'ABC',COL_B from TABLE_A WHERE COL_B=CONDITION`... (6 Replies)
Discussion started by: dinesh1985
6 Replies

6. Shell Programming and Scripting

Help with writing shell script file

I am trying to prompt the user using tput command to read the information ( 5 last names, first names and grades) from the keyboard. Save the data in a file called student.txt. Sort the file by last name and display it on the screen My pseudocode is as follow: Pseudocode: Initialize... (1 Reply)
Discussion started by: jestaton
1 Replies

7. Shell Programming and Scripting

newbie: writing ksh shell problem

my default profile is using ksh, I tried to write a simple scripts and I had issues, below is my scripts: $ more if_num.ksh USAGE="usage: if_num.ksh" print -n "Enter two numbers: " read x y if ((x=y)) then print "You entered the same number twice." when I tried to executed the... (6 Replies)
Discussion started by: matthew00
6 Replies

8. Shell Programming and Scripting

problem writing a simple c shell script

#!/bin/csh echo hello world this is what i got in a text file called ss1. i type "chmod 755 ss1.txt" to make it executable. then when i type ss1 or ss1.txt it says "ss1 command not found" what am i doing wrong? (19 Replies)
Discussion started by: pantelis
19 Replies

9. Shell Programming and Scripting

Sqlplus inside shell script writing to tmp file

Hi, facing an issue while calling sqlplus inside shell script. It for some reason goes to tmp file to write something and i get error as permission denied as i dont have access there. ANy idea why sqlplus writes in /tmp and how to change or stop this ? (2 Replies)
Discussion started by: rushikeshs
2 Replies

10. Programming

Writing a UNIX shell script to call a C function and redirecting data to a .txt file

Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far: #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: bjhjh
2 Replies
escape(1)                                                       Mail Avenger 0.8.3                                                       escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 08:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy