Sponsored Content
Top Forums Shell Programming and Scripting For loop and running 2 commands at once? Post 302398774 by Stephan on Thursday 25th of February 2010 01:54:10 PM
Old 02-25-2010
Quote:
Originally Posted by kshji
Start backup in background and wait process exit. Something like:
Code:
#!/someposixsh
backup1=( SA SC SE )
backup2=( SB SD SF )
round=0
roundmax=${#backup1[*]}
while (( round < roundmax ))
do
       backup "${backup1[$round]}" &
       pid1=$!
       backup "${backup2[$round]}" &
       pid2=$!
       wait $pid1
       wait $pid2
       echo done 
       ((round+=1))
done

Thanks for the input.

I am getting some problems with this though...

Variables backup1 and backup2 with the ( ) does not work. I tried to use " but not good either...

I understand what your scripts tries to do and it seems logical, but can't figure out how to get it to work though...

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

running start up commands

Hi all How can I setup my shell so that I run a set of commmands or a script every time I login. I am using kshell. I tried putting a line in ./.bash_profile (does not work) Ex.: I want to use vi as the commandline editor so, I want to run the command: set -o vi (3 Replies)
Discussion started by: skotapal
3 Replies

2. Shell Programming and Scripting

running commands from script

I'm new to unix and I have a fairly simple problem: Lets say I am in a specific directory and I run the command: "dirs" , I get an output of all the folders that i pushed into the stack (as expected), buut, when when I create a script (called test): #! /bin/csh dirs and then i run:... (2 Replies)
Discussion started by: owijust
2 Replies

3. Shell Programming and Scripting

How to disable running commands from vi

Hello, We have a requirement to disable running shell commands via vi using "!". Can anybody please suggest how to disable this option. The requirement arises because we open up a xterm window with a config file in vi mode for the customer to edit. After the customer edits the config... (1 Reply)
Discussion started by: Umesh_Sharoff
1 Replies

4. Shell Programming and Scripting

running commands from outside of bash

Hello all! I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this? Anyone can do something for my query? Click here if you can't understand my query or to know the need for this query. (3 Replies)
Discussion started by: rakabarp
3 Replies

5. Programming

Running shell commands from C/C++

Hi guys, I know using system() we can run unix commands but the problem is, I can't get any returns with the system(). I am returning stuff from my shell scripts that I need to be able to read from my C code. Anybody has cure to this problem? :)) Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

6. UNIX for Dummies Questions & Answers

Running two commands in one line

hi! how do i run 2 command from the same line e.g: 'which screen' and then ls -la 'which screen' (4 Replies)
Discussion started by: rdns
4 Replies

7. Shell Programming and Scripting

Running sed commands

Hello I need to run some sed commands but it involves "/" in the substitute or delete, any ideas how I get round the problem. Example: cat file1.txt | sed -e '/</Header>/d' > file2.txt This errors due to the forward slash before the Header text. Thanks (3 Replies)
Discussion started by: Dolph
3 Replies

8. Shell Programming and Scripting

Code for running commands one after other

I need an if code in shell script where it should continue to further commands after succesfully installing the executable file. i.e. /run installer is continuing but in the middle it executes further commands like "cp /root/user which were given after /run installer. I want /runinstaller... (16 Replies)
Discussion started by: sriki32
16 Replies

9. UNIX for Dummies Questions & Answers

Echo out running commands

Is there any way in a script to print out the commands being ran? In DOS script, there is the "@echo on" and "@echo off". so I have a script like this: #!/bin/ksh echo "hello there. moving files." <turn on echoing here> cp thisfile.txt thatfile.txt cp whatfile.prop whyfile.prop <turn... (2 Replies)
Discussion started by: ronron5477
2 Replies

10. Shell Programming and Scripting

Running two commands in background

Hi I want to run two commands in background, i am using below way, but it is not working, i m calling these two commands from one script to another server where below commands are running, in my script ssh is working fine, but command is not going in background, please advise what should i do. ... (10 Replies)
Discussion started by: learnbash
10 Replies
BACKUP_LISTHOSTS(8)					       AFS Command Reference					       BACKUP_LISTHOSTS(8)

NAME
backup_listhosts - Lists Tape Coordinators registered in the Backup Database SYNOPSIS
backup listhosts [-localauth] [-cell <cell name>] [-help] backup listh [-l] [-c <cell name>] [-h] DESCRIPTION
The backup listhosts command displays the Backup Database record of the port offset numbers defined for Tape Coordinator machines. A Tape Coordinator must have an entry in the list to be available for backup operations. The existence of an entry does not necessarily indicate that the Tape Coordinator process (butc) is currently running at that port offset. To check, issue the backup status command. OPTIONS
-localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. The backup command interpreter presents it to the Backup Server, Volume Server and VL Server during mutual authentication. Do not combine this flag with the -cell argument. For more details, see backup(8). -cell <cell name> Names the cell in which to run the command. Do not combine this argument with the -localauth flag. For more details, see backup(8). -help Prints the online help for this command. All other valid options are ignored. OUTPUT
After a "Tape hosts:" header, the output reports two things about each Tape Coordinator currently defined in the Backup Database: o The hostname of the machine housing the Tape Coordinator. The format of this name depends on the hostname format used when the backup addhost command was issued. o The Tape Coordinator's port offset number. The Tape Coordinators appear in the order in which they were added to the Backup Database. EXAMPLES
The following example shows the result of the command in the ABC Corporation cell: % backup listhosts Tape hosts: Host backup1.abc.com, port offset 0 Host backup1.abc.com, port offset 1 Host backup3.abc.com, port offset 4 Host backup2.abc.com, port offset 3 PRIVILEGE REQUIRED
The issuer must be listed in the /etc/openafs/server/UserList file on every machine where the Backup Server is running, or must be logged onto a server machine as the local superuser "root" if the -localauth flag is included. SEE ALSO
backup(8), backup_addhost(8), backup_delhost(8), backup_status(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 BACKUP_LISTHOSTS(8)
All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy