The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need docs. rimser9 Shell Programming and Scripting 2 03-11-2008 05:56 AM
Indent output of an UNIX command ssray23 UNIX for Dummies Questions & Answers 2 12-08-2005 07:52 AM
need HP-UX docs livemyway HP-UX 4 12-03-2005 04:38 AM
vim indent Virtuosso UNIX for Dummies Questions & Answers 4 02-06-2003 01:15 PM
Auto indent in vi sierra_aar UNIX for Dummies Questions & Answers 1 06-19-2002 07:36 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-20-2005
Registered User
 

Join Date: Jun 2005
Location: New York City
Posts: 95
[non-important] Indent here-docs?

I recently coded a typical ftp script looking like

Code:
ftp -n $hostname <<
user $user $pass
<commands..>
quit
!
I know the code fails when you try to indent it like:

Code:
    ftp $hostname <<
    user $user $pass
    <commands..>
    quit
    !
Just for the sake of neat code, is there a way to indent it at all (because I have that in an IF statement)?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-20-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,221
In ksh, you can use <<- which will delete leading TABs (but not spaces).
See here-documents.
Reply With Quote
  #3 (permalink)  
Old 06-21-2005
Registered User
 

Join Date: Jun 2005
Location: New York City
Posts: 95
hm..

I see, too bad I like using soft-spaces, instead of hard-tabs for fear it may not display correctly cross-platform.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 06-21-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 627
you could also make the ftp section into each own function and call that function when required ...

Code:
hostname=box
user=user1
pass=passWd1

ftp_files(){
ftp -inv $hostname << !
user $user $pass
<commands..>
quit
!
}

if [ cond ]
then
    ftp_files
else
    <commands...>
fi
Reply With Quote
  #5 (permalink)  
Old 06-21-2005
Registered User
 

Join Date: Jun 2005
Location: New York City
Posts: 95
good idea.

Ahh, good idea. Thanks.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:34 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