LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-22-2012, 12:46 PM   #1
DavidLee1A
Member
 
Registered: Dec 2012
Distribution: Debian Wheezy amd64
Posts: 123
Blog Entries: 12

Rep: Reputation: 5
How to use Vi editor to run a script from LFS website


checking my host system requirements using the LFS script located at: http://www.linuxfromscratch.org/lfs/.../hostreqs.html
It starts with cat > version-check.sh << "EOF"
and ends with EOF

What is the best way to modify this to write it in the Vi editor?
Do I have to change the cat command and do something like
~$ Vi version-check.sh ? Then, how do I have to modify the script? I already typed the entire script verbatim and called the file versioncheck.
 
Old 12-22-2012, 12:56 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
It is a so called here document, the cat command writes the text between << "EOF" and EOF into the file named version-check.sh

If you want to do it with an editor you would have to type the complete script manually or copy and paste it from the website.

To write it manually do
Code:
vi version-check.sh
then you are in the editor. You would have to leave the first line (with the cat command) and everything from EOF to the end. But afterwards you would have to execute (after closing the editor)
Code:
bash version-check.sh
Markus

BTW: most easy is to copy the complete script into a terminal and press the <ENTER> key.
Then happens this
Code:
markus@samsung:~$ cat > version-check.sh << "EOF"
> #!/bin/bash
> # Simple script to list version numbers of critical development tools
> 
> export LC_ALL=C
> bash --version | head -n1 | cut -d" " -f2-4
> echo "/bin/sh -> `readlink -f /bin/sh`"
> echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
> bison --version | head -n1
> if [ -e /usr/bin/yacc ];
>   then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; 
>   else echo "yacc not found"; fi
> 
> bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
> echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
> diff --version | head -n1
> find --version | head -n1
> gawk --version | head -n1
> if [ -e /usr/bin/awk ];
>   then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; 
>   else echo "awk not found"; fi
> 
> gcc --version | head -n1
> ldd --version | head -n1 | cut -d" " -f2-  # glibc version
> grep --version | head -n1
> gzip --version | head -n1
> cat /proc/version
> m4 --version | head -n1
> make --version | head -n1
> patch --version | head -n1
> echo Perl `perl -V:version`
> sed --version | head -n1
> tar --version | head -n1
> echo "Texinfo: `makeinfo --version | head -n1`"
> xz --version | head -n1
> 
> echo 'main(){}' > dummy.c && gcc -o dummy dummy.c
> if [ -x dummy ] 
>   then echo "gcc compilation OK";
>   else echo "gcc compilation failed"; fi
> rm -f dummy.c dummy
> EOF
markus@samsung:~$ 
markus@samsung:~$ bash version-check.sh
bash, version 4.2.37(2)-release
/bin/sh -> /bin/bash
Binutils: (Linux/GNU Binutils) 2.22.52.0.2.20120424
bison (GNU Bison) 2.5.1
/usr/bin/yacc -> /usr/bin/yacc
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.19
diff (GNU diffutils) 3.2
find (GNU findutils) 4.4.2
GNU Awk 3.1.8
/usr/bin/awk -> /bin/gawk-3.1.8
gcc (GCC) 4.7.1
(GNU libc) 2.15
grep (GNU grep) 2.14
gzip 1.5
Linux version 3.5.4 (root@srv-zuhause) (gcc version 4.7.1 (GCC) ) #1 SMP Sun Sep 23 12:15:31 CEST 2012
m4 (GNU M4) 1.4.16
GNU Make 3.82
GNU patch 2.7
Perl version='5.16.1';
GNU sed version 4.2.1
tar (GNU tar) 1.26
Texinfo: makeinfo (GNU texinfo) 4.13
xz (XZ Utils) 5.0.4
gcc compilation OK
markus@samsung:~$

Last edited by markush; 12-22-2012 at 12:59 PM.
 
1 members found this post helpful.
Old 12-22-2012, 01:21 PM   #3
DavidLee1A
Member
 
Registered: Dec 2012
Distribution: Debian Wheezy amd64
Posts: 123
Blog Entries: 12

Original Poster
Rep: Reputation: 5
Markush, Thank You for the quick reply! I would cut and paste but for many reasons:
1) I am on Chapter 7 of: http://rute.2038bug.com/node10.html.gz and he says everyone should be familiar with Vi
2) The work is being done on another computer that has a minimal Debian install and commands like | less and lynx don't seem work, I haven't even connected to a website from there yet ... so, no pasting yet

It will be a few hours and I'll post how this worked. Thank you again.
 
Old 12-22-2012, 01:23 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
If you want to learn vi, I would recommend to do it on a computer where vim is installed (which is a vi clone). vim comes with an interactive tutorial, simply type
Code:
vimtutor
in a terminal.

Markus
 
Old 12-24-2012, 05:47 PM   #5
DavidLee1A
Member
 
Registered: Dec 2012
Distribution: Debian Wheezy amd64
Posts: 123
Blog Entries: 12

Original Poster
Rep: Reputation: 5
well markush, I did a round of vimtutor and wrote this:
Code:
#!/bin/bash

# Simple script to list version numbers of critical development tools

export LC_ALL=C

bash --version | head -n1 | cut -d" " -f2-4

echo "/bin/sh -> `readlink -f /bin/bash`"

echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-

bison --version | head -n1

if [ -e /usr/bin/yacc ];

  then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";

  else echo "yacc not found"; fi

bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-

echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2

diff --version | head -n1

find --version | head -n1

gawk --version | head -n1

if [ -e /usr/bin/awk ];

  then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";

  else echo "awk not found"; fi

gcc --version | head -n1

ldd --version | head -n1 | cut -d" " -f2- # glibc version

grep --version | head -n1

gzip --version | head -n1

cat /proc/version

m4 --version | head -n1

make --version | head -n1

patch --version | head -n1

echo Perl `perl -V:version`

sed --version | head -n1

tar --version | head -n1

echo "Texinfo: `makeinfo --version | head -n1`"

xz --version | head -n1

echo 'main(){}' > dummy.c && gcc -o dummy dummy.c

if [ -x dummy ]

  then echo "gcc compilation OK";

  else echo "gcc compilation failed"; fi

rm -f dummy.c dummy

done
but I don't think I should have written done at the end b/c I get a syntax error unexpected token message at the end of this:
Code:
learner@host:~$ bash version-check.sh

bash, version 4.1.5(1)-release

/bin/sh -> /bin/bash

Binutils: (GNU Binutils for Debian) 2.20.1-system.20100303

bison (GNU Bison) 2.4.1

/usr/bin/yacc -> /usr/bin/bison.yacc

bzip2,  Version 1.0.5, 10-Dec-2007.

Coreutils:  8.5

diff (GNU diffutils) 3.0

find (GNU findutils) 4.4.2

GNU Awk 3.1.7

/usr/bin/awk -> /usr/bin/gawk

gcc (Debian 4.4.5-8) 4.4.5

(Debian EGLIBC 2.11.3-4) 2.11.3

GNU grep 2.6.3

gzip 1.3.12

Linux version 2.6.32-5-amd64 (Debian 2.6.32-46) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Sun Sep 23 10:07:46 UTC 2012

m4 (GNU M4) 1.4.14

GNU Make 3.81

patch 2.6

Perl version='5.10.1';

GNU sed version 4.2.1

tar (GNU tar) 1.23

Texinfo: makeinfo (GNU texinfo) 4.13

xz (XZ Utils) 5.0.0

gcc compilation OK

learner@host:~$ vim version-check.sh

learner@host:~$ bash version-check.sh

bash, version 4.1.5(1)-release

/bin/sh -> /bin/bash

Binutils: (GNU Binutils for Debian) 2.20.1-system.20100303

bison (GNU Bison) 2.4.1

/usr/bin/yacc -> /usr/bin/bison.yacc

bzip2,  Version 1.0.5, 10-Dec-2007.

Coreutils:  8.5

diff (GNU diffutils) 3.0

find (GNU findutils) 4.4.2

GNU Awk 3.1.7

/usr/bin/awk -> /usr/bin/gawk

gcc (Debian 4.4.5-8) 4.4.5

(Debian EGLIBC 2.11.3-4) 2.11.3

GNU grep 2.6.3

gzip 1.3.12

Linux version 2.6.32-5-amd64 (Debian 2.6.32-46) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Sun Sep 23 10:07:46 UTC 2012

m4 (GNU M4) 1.4.14

GNU Make 3.81

patch 2.6

Perl version='5.10.1';

GNU sed version 4.2.1

tar (GNU tar) 1.23

Texinfo: makeinfo (GNU texinfo) 4.13

xz (XZ Utils) 5.0.0

gcc compilation OK

version-check.sh: line 37: syntax error near unexpected token `done'

version-check.sh: line 37: `done'
But I still get the information I needed so: Thank you
 
Old 12-25-2012, 02:34 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Just type everything in between cat > version-check.sh << "EOF" and EOF (both not included) and do not add anything else.

The LFS book uses a here-document (as already mentioned by markush in posr #2). Here is a link explaining this construct: Here Documents (ABSG)
 
Old 12-25-2012, 03:31 AM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
The syntax error is the word 'done' which doesn't belong into the file.

Markus
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] LFS WebSite !! mbzadegan Linux From Scratch 2 10-30-2011 03:45 PM
what is a good website editor for fedora olracdor Linux - Software 2 11-15-2008 02:47 PM
LFS website empty rangalo Linux From Scratch 6 11-18-2006 01:44 AM
LFS website down? Paulsuk Linux From Scratch 2 11-04-2006 08:34 AM
Idea for LFS Website RecoilUK Linux From Scratch 1 06-01-2002 06:25 PM


All times are GMT -5. The time now is 09:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration