Sponsored Content
Top Forums Shell Programming and Scripting Running a unix script(which is calling another script inside that) in background Post 302368902 by rohithji on Friday 6th of November 2009 12:52:57 AM
Old 11-06-2009
Running a unix script(which is calling another script inside that) in background

Hi ,

I have one main script called script1.sh which contains the cotennts below. this script wil search for the existence of files in a particular directory and if one file is finidin it wil send to another server . this is the basic functionality
the script1.sh is given below


#Al the directiory locations wil be mentinedin the first

# Trace output function
trace ()
{
if [ $TRACE ]
then
DATE=`date +"%Y-%m-%d %X"`
echo "$DATE: $1" >> $TRACEFILE
fi
}

trace "Script $0 started"

# First find all alarm files to import at start
FILES="`find $ALARM_FILES_DIR -type f`"

# Loop forever and import files
while [ true ]
do
loop=`expr $loop + 1`

# cat the files to a text file
if [ "$FILES" != "" ]
then
FILES_SORTED="`ls -rt $FILES`"
trace "Alarm files to import:\n$FILES_SORTED"

for i in $FILES_SORTED
do
cat $i>export1.txt

username=***
password=***

expect -c "
# exp_internal 1 # uncomment for debugging

spawn /usr/bin/scp export1.txt ***@ipaddress:/location

expect {
"*password:*" { send $password\r\n; interact }
eof { exit }

}
exit
"
/export/home/netcool/rohith/script.sh
rm -rf export1.txt

echo
done

LATEST="$i"
SENDHB=false
else
trace "No new alarm files to import"
SENDHB=true
fi

trace "Latest alarm file imported: $LATEST"

#
# If the latest file sent still exists then find newer files, otherwise find all files
if [ -f "$LATEST" ]
then
FILES="`find $ALARM_FILES_DIR -newer $LATEST -type f`"
else
FILES="`find $ALARM_FILES_DIR -type f`"
fi
# Modify sleep time (in seconds) as needed below
sleep 2

done

THIS SCRIPT WIL CALL THE SECOND SCRIPT CALLED SCRIPT.SH contents given below since expect cant used inside the first script i hav given like dat in dif script i mean /usr/bin/expect -f

#!/usr/local/bin/expect -f
spawn ssh ***@ipaddrss 'location/ssh.sh'
expect "password:"
send "netcool\n"
interact

This wil call another script in server2 called ssh.sh contents are given below

#!/bin/sh
cat export1.txt >> export.txt
rm export1.txt


I need to execute all these 3 scripts in crontab for copyn the files automatically.

I am really a beginner in scripting. I know some logical mismatch may be der . PLease correct me and help me out for solving this.

REgards,

ROhith G
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling a C executable from inside a Perl script

here's the Perl code snippet... how can i call my C executable 'porter-stemmer' and pass it $1 as an argument? Thanks for the help! # Read through the original topic set, and modify based on the current # pre-processing options while (<TOPIC_ORIG>) { # Run pre-processing over only the... (3 Replies)
Discussion started by: mark_nsx
3 Replies

2. Shell Programming and Scripting

differences in calling another script inside script

Hello, we can call the script inside another script. like method 1) content of test.sh ######## . test2.sh ####### method 2) content of test.sh ######## test2.sh ####### What is the difference here in both samples calling test2.sh?? i mean calling with ". " and calling... (1 Reply)
Discussion started by: balareddy
1 Replies

3. UNIX for Dummies Questions & Answers

Running the Script in Background.

Gurus, Pls. help on this to run the script in background. I have a script to run the informatica workflows using PMCMD in script. Say the script name is test.sh & Parameters to the script is Y Y Y Y The no of parameters to the bove script is 4. all are going to be a flags. Each flag will... (2 Replies)
Discussion started by: prabhutkl
2 Replies

4. UNIX for Advanced & Expert Users

Running script in background

When I run the following snippet in background #!/bin/ksh while do echo "$i" sleep 10 i=`expr $i + 1` done My job got stopped and it says like + Stopped (SIGTTOU) ex1 & I did "stty tostop" as suggested in many of the post but still not working... (3 Replies)
Discussion started by: shahnazurs
3 Replies

5. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

6. Shell Programming and Scripting

running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the... (3 Replies)
Discussion started by: maitree
3 Replies

7. Shell Programming and Scripting

Problem in calling a script inside a script

Hi team, I have a script in different folder. Now i want to call that script and execute that script from that path alone. My code is #!/bin/bash wname=yahoo PATH='/opt/IBM' wac=`/usr/bin/ls $PATH | /usr/bin/grep "$wname"` STOP=`/usr/bin/find $PATH/$wac -type f -name "stop.sh"`... (8 Replies)
Discussion started by: natraj005
8 Replies

8. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

9. Shell Programming and Scripting

Calling one script inside another

Hi, I am calling a script log.sh from output.sh. Log.sh has below pice of code: IFILE=/home/home1/Report1.csv if awk -F, '$6==0 && $7==0{exit 1}' ${IFILE} then awk -F, ' BEGIN{ c=split("1,6,2,3,4,5,6", col) print "To: abc@gmail.com" print "Subject: Error... (2 Replies)
Discussion started by: Vivekit82
2 Replies

10. Shell Programming and Scripting

Running script in background

Hi, I wrote a KSH script and running it on HP-UX machine I am running one script in background. My script is at location $HOME/myScript/test/background_sh When I view my script in background with psu commend > psu | grep background_sh I see following output UID PID PPID C ... (1 Reply)
Discussion started by: vaibhav
1 Replies
gnomevfs-cat(1) 						   User Commands						   gnomevfs-cat(1)

NAME
gnomevfs-cat - print a file to standard output using the VFS system SYNOPSIS
gnomevfs-cat URI DESCRIPTION
gnomevfs-cat is obsolete. It has been superseded by gvfs-cat. See gvfs-cat(1). gnomevfs-cat prints a file to standard output using the virtual file system to access the file via a URI. OPERANDS
The following operands are supported: URI Specifies the file location in standard URI format. EXAMPLES
Example 1: Cat a File From a Web Server example% gnomevfs-cat http://www.sun.com Example 2: Cat a Local File example% gnomevfs-cat file:///home/user/README.txt ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables: NLSPATH. EXIT STATUS
The exit value 0 is returned regardless of success or failure. FILES
The following files are used by this application: /usr/bin/gnomevfs-cat Executable to print a file to standard output using the VFS system ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-vfs | +-----------------------------+-----------------------------+ |Interface stability |Obsolete Volatile | +-----------------------------+-----------------------------+ SEE ALSO
gnomevfs-copy(1), gnomevfs-info(1), gnomevfs-ls(1), gnomevfs-mkdir(1), gvfs-cat(1), attributes(5), environ(5) NOTES
Written by Stephen Browne, Sun Microsystems Inc., 2004. SunOS 5.11 14 May 2008 gnomevfs-cat(1)
All times are GMT -4. The time now is 04:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy