Sponsored Content
Top Forums Shell Programming and Scripting Advice needed on using Script with NOHUP Post 302403075 by bharath.gct on Thursday 11th of March 2010 10:28:44 AM
Old 03-11-2010
Advice needed on using Script with NOHUP

All,

I would like to know my below requirement can be achieved in any way in Shell Scripting? I will make this requirement of mine as understandable as I can.

Requirement:
I wrote a script 'my.script' which gets user-input tablenames and puts the same into an array. Also I get other inputs like logon credentials, Source Database name etc.

I process all the inputs to generate a 'fexp.exec' script on the fly. Then I am trying to execute the 'fexp.exec' script from 'my.script', to start the FastExport process (Teradata Utility to unload the source DB tables to the Unix environment as files). And once 'fexp.exec' script (FastExport) completes, the control returns back to the 'my.script' where I am validating the output files (created from the FastExport) based on the entered input files.

This whole effort is to automate the Unloading of tables from DB to Unix. Before writing the 'my.script', I used to prepare the 'fexp.exec' script manually and run it with a NOHUP (something like the code below), so that i can allow it to run in the background (as FastExport runs for 2 hours).

Code:
nohup ksh fexp.exec &

Question:
But now with this effort to automate, I have a requirement to run the 'fexp.exec' script from 'my.script'. And I want the 'fexp.exec' script to be run in the background. Also I do not want to make the my.script run for 2 hours as well!

I know I can just give the above line of code in my 'my.script' file to run the FastExport in the background. But I have the validation of the output files (created from FastExport) based on the entered input files, in 'my.script'. And immediately once after nohup of 'fexp.exec', the validation part in 'my.script' continues and it fails as the output files are not present as the fexp.exec is still running in the background.

To resolve this I see a few ways, but none of them are fruitful. I would need some advise on how to proceed with my condition here!

1. I can put a wait command after the nohup of fexp.exec, but that would make the my.script to wait for 2 hours, which I dont need.

2. I can nohup the my.script file itself but the script accepts user-input in various parts of the script.

3. I tried to echo the validation part into the fexp.exec script after the FastExport commands, so that I can just nohup the 'fexp.exec' and allow the my.script to run to completion once fexp.exec is nohup-ed. For this I have to pass the array that I received in my.script to fexp.exec. But that again is not working. I can post the code for this if you want.

Is there anyother way to achieve my requirement. I am sorry for writing a long story here. Hope I am not confusing anyone. Please let me know if you have any questions. Any help is very greatly appreciated.

p.s: I can post the code for the requirement or the #3 above, if anyone needs it for more understanding. i am not posting the code now just to prevent my post being toooo long Smilie

Thanks
Bharath
 

10 More Discussions You Might Find Interesting

1. Linux

programming advice needed....

i'm a grad student taking a UNIX course and a networks course (i have a background in C++ and JAVA). i'm trying to combine the two classes. My questions stems from a networks programming homework assignment below: "Using the operating system and language of your choice, develop a program to... (5 Replies)
Discussion started by: trostycp
5 Replies

2. Solaris

Using San storage - advice needed

Thinking of using our San for network backups.. Have a Netra 240 being installed and planning to get some space on our San. Do you know what software is used to access the San from my server or what I would need to do? I know how to connect to local storage, disk arrays etc but not sure what... (1 Reply)
Discussion started by: frustrated1
1 Replies

3. Shell Programming and Scripting

eval problem.. advice needed!

Hi I need some major help with eval I have a statement using eval: read input eval variable$input=”something” Now I want to use the “variable$input” in some commands but I don't know how to call it without replacing the $input with the command line value (which I obviously can't do). ... (1 Reply)
Discussion started by: Cactus Jack
1 Replies

4. Linux

GUI builder advice needed ......

Hello all, I need to develop an application that would be used as a simulator to test various custom algorithms. As I have never embarked on this kind of work, I need some advice: 1. Which GUI library to use in Linux, GTK+ or FLTK? The simulator application needs to output various... (2 Replies)
Discussion started by: fox_hound_33
2 Replies

5. Filesystems, Disks and Memory

LVM resizing advice needed

Hi I have a CentOS 5 server with LVM. / and /home are low on disk space. I have ~12Gb available on /usr I plan to resize /usr and add the available space to the other 2 partitions. Please advice me on any precautions I need to take. Any problem if you have faced doing similar stuff and... (0 Replies)
Discussion started by: yunusyb
0 Replies

6. Shell Programming and Scripting

'for' loop advice needed ....!!

/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}' I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine. ... (4 Replies)
Discussion started by: ak835
4 Replies

7. UNIX for Advanced & Expert Users

'for' loop advice needed....!!

Scenario: Command used to capture IPs on a host: /usr/sbin/ifconfig -a | grep "inet" | egrep -v "inet6|0.0.0.0|192.168.100.2" | awk '{print $2}' Following for loop used to capture interface names: for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 {sub(":$", "", $1); print... (3 Replies)
Discussion started by: ak835
3 Replies

8. Linux

Scripting advice needed

Evening all, Im trying to get a script that will: Select the most 3 recent files in a specific directory Run a command on them (like chmod) Ask of you would like to continue Copy the files to another directory If a linux guru could help me out, it would be very much appreciated. Thanks... (2 Replies)
Discussion started by: Wiggins
2 Replies

9. UNIX for Dummies Questions & Answers

Help needed for nohup time

Hi All, Firstly thanks for reading my query..I am a complete newbie in Unix and I recently read about nohup command which is responsible to continue execution in background. But I have found some command where time is used alongwith nohup as given below:- nohup time A.sh & I don't know why... (2 Replies)
Discussion started by: saswati16
2 Replies

10. Solaris

Solaris Study Advice Needed

I just have a question regarding learning Solaris, I have a Linux and AIX background and I would like to learn Solaris, I have been giving some Solaris 10 Study Guides and just wondered how relevant they would be to Solaris 11 or should I try and get some study materials which are targeted towards... (1 Reply)
Discussion started by: markmorris182mx
1 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-c COMMAND] [-e] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -e Return the exit code of the child process. Uses the same format as bash termination on signal termination exit code is 128+n. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), scriptreplay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. AVAILABILITY
The script command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 08:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy