Sponsored Content
Full Discussion: Read file and run a command
Top Forums Shell Programming and Scripting Read file and run a command Post 302934947 by karan8810 on Thursday 12th of February 2015 04:41:18 AM
Old 02-12-2015
Read file and run a command

Hi

I have jobs (some 1000) defined in a file and I want to read those jobs and run a a command.

For example:
jobs.txt

Code:
abc
efg

I want to read the entire file and run the following command
Code:
Delete -JOB "abc"
Deleteing abc...
Delete -JOB "efg"
Delete efg...

Can somebody help me with the shell script to do the following.

Many Thanks in advance
Karan

Last edited by Don Cragun; 02-12-2015 at 06:05 AM.. Reason: Add CODE tags again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read line and run a different command according to the output

Hi. I'm trying to write a script that reads a line on a file and runs a different command for a different line output. For example, if it finds the word "Kuku" on the line it sends mail to Kuku@kuku.com. Otherwise, it sends mail to Lulu@lulu.com. TIA. (2 Replies)
Discussion started by: Doojek9
2 Replies

2. Shell Programming and Scripting

Run Command from file

Hi Guys, I have few commands in one text file in below location and i want run it in unix. Thanks (2 Replies)
Discussion started by: asavaliya
2 Replies

3. Shell Programming and Scripting

Read 2 lines from File, Run Command based off output

Okay, so I have a file containing line after line of three digit numbers. I need a script that does an action based on the last two numbers in this list. So.... To get the last two numbers, I can have the script do tail -2 filename.txt But where I run into trouble is as follows. If... (6 Replies)
Discussion started by: UCCCC
6 Replies

4. Shell Programming and Scripting

sh file: READ (menu) but now run with option

I have a script which uses READ to detect choice of menu option...now I want to change the script without doing whole rewrite such that when user runs ./script.sh 5 it would execute menu option 5 rather than user running ./script.sh waiting for it to load and then pressing "5 enter" Is it... (1 Reply)
Discussion started by: holyearth
1 Replies

5. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

6. UNIX for Dummies Questions & Answers

Read workstation list from file und run command

Hi, how do I read in a file which includes a list of workstations and then run a command for each workstation ? I am unclear which command to use to read in , or is this not possible ? Thanks, (3 Replies)
Discussion started by: manni2
3 Replies

7. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

8. Shell Programming and Scripting

Read xml file till script finds separation and run again for next input and so on

Hi All, I have one query, I managed to run script with user inputs through command line or with 1 file. But I need to read a txt file/xml file in which user can mention multiple sets of answers and script should run for each set till it reach the EOF. Thanks in advance for example, the file... (3 Replies)
Discussion started by: rv_champ
3 Replies

9. Shell Programming and Scripting

Read in txt file and run a different command for each line

hi, i'm trying to write a tcsh script that reads in a text file (one column) and the runs a different command for each line of text. i've found lots of example commands for bash, but not for tcsh. can anyone give me a hint? thanks, jill (8 Replies)
Discussion started by: giuinha
8 Replies

10. Shell Programming and Scripting

Script to read file and run multiple jobs

I have a txt file line1 line2 line3 $!/bin/sh cat /tmp/lus.txt | while read line do esxcli storage vmfs unmap -u $lin -n 4000 done this works but does in one line at a time. how do I do all lines at once simutaeously? Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: tdubb123
4 Replies
starting(7)						 Miscellaneous Information Manual					       starting(7)

NAME
       starting - event signalling that a job is starting

SYNOPSIS
       starting JOB=JOB INSTANCE=INSTANCE [ENV]...

DESCRIPTION
       The  starting  event is generated by the Upstart init(8) daemon when a new instance of a job begins starting.  The JOB environment variable
       contains the job name, and the INSTANCE environment variable contains the instance name which will be empty for single-instance jobs.

       init(8) will wait for all services started by this event to be running, all tasks started by this event	to  have  finished  and  all  jobs
       stopped by this event to be stopped before allowing the job to continue starting.

       This allows jobs to effectively insert themselves as dependencies of other jobs.  The event is typically combined with the stopped(7) event
       by services.

       Job configuration files may use the export stanza to export environment variables from their own environment into the starting event.   See
       init(5) for more details.

EXAMPLE
       A service that wishes to be running whenever another service would be running, started before and stopped after it, might use:

	      start on starting apache
	      stop on stopped apache

       A task that must be run before another task or service is started might use:

	      start on starting postgresql

SEE ALSO
       started(7) stopping(7) stopped(7) init(5)

Upstart 							    2009-07-09							       starting(7)
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy