The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 09:56 AM
Indent output of an UNIX command ssray23 UNIX for Dummies Questions & Answers 2 12-08-2005 11:52 AM
need HP-UX docs livemyway HP-UX 4 12-03-2005 08:38 AM
vim indent Virtuosso UNIX for Dummies Questions & Answers 4 02-06-2003 05:15 PM
Auto indent in vi sierra_aar UNIX for Dummies Questions & Answers 1 06-19-2002 10:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-20-2005
yongho yongho is offline
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)?
  #2 (permalink)  
Old 06-20-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
In ksh, you can use <<- which will delete leading TABs (but not spaces).
See here-documents.
  #3 (permalink)  
Old 06-21-2005
yongho yongho is offline
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.
  #4 (permalink)  
Old 06-21-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
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
  #5 (permalink)  
Old 06-21-2005
yongho yongho is offline
Registered User
  
 

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

Ahh, good idea. Thanks.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0