The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Why generate "ash and bash" different output for same bash script? s. murat Shell Programming and Scripting 0 05-26-2008 04:19 AM
Processing extended ascii character file names in UNIX (BASH scipts) peli UNIX for Advanced & Expert Users 9 04-06-2008 02:17 PM
bash:awk output into an array phamp008 Shell Programming and Scripting 2 03-16-2008 01:14 AM
Bash multiple output redirection yoi2hot4ya Shell Programming and Scripting 2 05-31-2005 09:52 AM
Disk Formated with NTFS bache_gowda Linux 4 11-19-2003 01:05 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: May 2008
Posts: 2
processing tab-formated output of command w/bash

I have a command that when ran it will have an output such as

string LongerString
string2 longerString2
More MoreStrings

seperated by tabs. The command lists domains and their accounts set up in my server admin software (interworx).

The end result will be that it will run rsync for each of the domain accounts.

For example.

rsync -a /home/account/domain/html {backupserver}:~/backup/domain/html

if i try something like
for domain in `/home/interworx/bin/listaccounts.pex`
do
echo $domain
done;

it just prints out each word on its own line.

i've tried different forms of
while read line;
do
echo "${line}"
done < script_command and it always returns something like

./test.sh: line 4: xxxxxo xxxxxxxxxx.com
lxxxxn xxxxxxx.net
unxxxxxxe xxxxx.net: No such file or directory




Any ideas ?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: Jan 2008
Posts: 18
Take a look at the rsync man page. Maybe you could simplify your life and use the following:
--files-from=FILE read list of source-file names from FILE

Just an idea. Not sure if it's exactly what you're looking for.
Reply With Quote
  #3 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: May 2008
Posts: 2
well, to provide a more in depth example of what i was hoping to acheive:


The script would perform the following, in order...

# cd /home/interworx/bin/

# run listdomains.pex which returns domains set up on server.
# output from that tool is as follows
# lfguildn lf-guild.net
# domain2 domain2.com

$account = lfguildn
$domain = lf-guild.net

# start loop on each line from listdomains.pex

# run backup.pex which backs up domain information from host control panel on each domain.

# scp partial backup .tar.gz from /home/$account/$domain/iworkx-backup/*{$date}.tgz

#perform rsync of HTML data from web directory
#make backup.hostname:~/webdata/$account/html directory if not exist

#rsync -av /home/$account/$domain/html/ backup.user@backup.hostname:~/webdata/$account/html/

The end goal is to have a tool that can be used to back up any dedicated server that one has leased at Sagonet.com and uses the Interworx Control Panel.

The only thing i cant figure out is how to to loop, line by line, on the output of a command in bash scripting.

I could write this as a php tool (or perl), but i'd rather use straight bash to make it simple and fast.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0