[non-important] Indent here-docs?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [non-important] Indent here-docs?
# 1  
Old 06-20-2005
[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  
Old 06-20-2005
In ksh, you can use <<- which will delete leading TABs (but not spaces).
See here-documents.
# 3  
Old 06-21-2005
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  
Old 06-21-2005
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  
Old 06-21-2005
good idea.

Ahh, good idea. Thanks. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse excel with indent

hello everyone how to parse excel file with indents ? i was trying perl and there is Spreadsheet::ParseExcel::Format but i have no idea how to make it work docs says $format->{Indent} but it's not working also i was trying xls2csv and xlhtml but they don't care about indents at all :( i... (1 Reply)
Discussion started by: tip78
1 Replies

2. Shell Programming and Scripting

Python indent - how do you do it?

A space, a tab? Just currious what, why, you indent in x way? Fwiw, I use vi, so kind'a currious how you vi folks approach indentation when writing code (eg python). Disclosure, I'm just learning python and have never seen a language use indentation so formally (I like it too:) ). I just... (7 Replies)
Discussion started by: sas
7 Replies

3. Solaris

Where did the docs go?

Did you ever wonder what Oracle did with the Sun Documentation? It's still out there but it's not that easy to find even with their new wiz-bang "My Oracle Support" page. I found this site today with links directly to the documentation. I hope everyone find this useful: Where'd the Docs Go?... (2 Replies)
Discussion started by: bluescreen
2 Replies

4. Shell Programming and Scripting

How to indent the file lines using vi?

Every now and then I have to indent the lines in my script to 4 space characters. I generally do it line by line. Is there an automated command in vi using which I can indent some set of lines to desired number of space characters in one go. (2 Replies)
Discussion started by: paragkalra
2 Replies

5. Web Development

How to indent the second line of text in html?

Hi, I have 3 lines in a text and i want to indent the 2nd line of the text. How can i do that in html? Here is the text. 1: XYZ. 2009 Jul 14. Perl is a scripting language. Perl is a high-level, general-purpose, interpreted, dynamic programming language ID: 2547999 The output... (1 Reply)
Discussion started by: vanitham
1 Replies

6. UNIX for Dummies Questions & Answers

vi auto indent whole file at once

Hi, I'm working on a big project and all the CPP and header files are in mess with respect to indentation. I would like to indent whole file(s) at once (like ctrl-shift-f in eclipse). Is there anybody who knows how to do that in vi/vim? thanks (2 Replies)
Discussion started by: SaTYR
2 Replies

7. Shell Programming and Scripting

need docs.

Hi , Im not into much of a perl and now I have work on some perl scripts which use commands like Config::Tiny, Use Data:Dumper etc. Can any one provide insight into these commands or any documents are also more than welcomed. Thanks, (2 Replies)
Discussion started by: rimser9
2 Replies

8. HP-UX

need HP-UX docs

hi everyone I m plannin to study the HP-UX can anyone supply me with some docs or ebooks or any links for free download. thanks in advance (4 Replies)
Discussion started by: livemyway
4 Replies

9. UNIX for Dummies Questions & Answers

vim indent

I know this is not a unix question but I also know that many of you use vim editor every day. So hoping to get some help, here it goes: How can I change my vim config file so that the indentations while c programming take 4 spaces instead of 8? I want the change to apply any further uses of... (4 Replies)
Discussion started by: Virtuosso
4 Replies

10. UNIX for Dummies Questions & Answers

Auto indent in vi

Hi, I use vi for my text editing. Is there a way to use smart indentation? that is when adding a '{' or '}' that the editor will jump and advance, or any other thing like that? thanks (1 Reply)
Discussion started by: sierra_aar
1 Replies
Login or Register to Ask a Question