LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2007, 01:08 AM   #1
dcj1978
LQ Newbie
 
Registered: Aug 2007
Location: Northern California
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
Teaching myself Linux. Hit a road block


First off, this is my first post here. I've read through a few now and so far, I can tell i'm gonna learn a lot here.

As for my question, i'm teaching myself Linux. I've been running Ubuntu for a couple days now and I decided i'd dig into some tutorials to really figure out how things work.

The tutorial i'm going through now is to the point where it's explaining shell scripts and how they can be used. I've been able to edit and run the "today" function and did the ever popular "Hello World!" script and both went fine.

The next thing that was in line was, using a shell script to create a web page. I do a lot of web page work so..I thought this sounded really cool. I just can't seem to get it to work though. Here's my code for the script named 'make_page'...

Code:
#!/bin/bash

# make_page - A script to produce an HTML file

cat <<- _EOF_
    <HTML>
    <HEAD>
        <TITLE>
        My System Information
        </TITLE>
    </HEAD>

    <BODY>
    <H1>My System Information</H1>
    </BODY>
    </HTML>
_EOF_
I save that to my home directory, and then, this is what I put into the terminal..

myname@ubuntu:~$ make_page > make_page.html

I get this error..

bash: make_page: command not found

..but it does create a blank HTML file..with the correct name, in that directory.

I'd appreciate any help I can get so I can continue with this tutorial. Whew...long first post.

Thanks!
 
Old 08-05-2007, 01:23 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
There are "environment variables" in the shell, one of which is PATH, which is a list of directories to be searched when you type the name of an executable. You get the error message you're seeing because the shell can't find "make_page" in any of those directories. To run an executable that's located in a directory not in the PATH, you have to use the entire path. If the executable is in the current directory, you can prefix it with "./", which is shorthand for the absolute path to the current directory. So, use "./make_page > make_page.html".

Edit: oh and welcome to LQ .
 
Old 08-05-2007, 01:34 AM   #3
dcj1978
LQ Newbie
 
Registered: Aug 2007
Location: Northern California
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: 0
Ah! Very cool. Looked that up and it gave a walkthrough on adding dir's to the list. Very handy.

Working like a charm now.

Oh, and thanks, good to be here! Already working out quite well for me. heh
 
Old 08-05-2007, 01:38 AM   #4
GregLee
Member
 
Registered: Feb 2004
Location: Waimanalo, HI
Distribution: Slackware 10, Fedora 6
Posts: 308

Rep: Reputation: 30
You didn't make the file "make_page" executable (from what you say): "chmod +x make_page". The part of your statement "> make_page.html" created the file "make_page.html". It's also possible that, as Nylex says, the current directory is not in the list of directories searched for commands (though it is in that list, ordinarily). You can check by looking at the output of "echo $PATH" to see if there is a "." there.
 
Old 08-06-2007, 01:35 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,174

Rep: Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682Reputation: 2682
Actually, the current dir is normally NOT in the PATH for security reasons ie someone drops an evil ver of ls into your dir and you are 'owned'.
Originally this was just in root's acct, but it seemed like a good idea for everyone.

Last edited by chrism01; 08-06-2007 at 06:55 PM.
 
Old 08-06-2007, 05:33 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,494

Rep: Reputation: 235Reputation: 235Reputation: 235
Shhh!
http://www.unix.org.ua/orelly/unix/upt/index.htm
 
  


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
Teaching Linux madunix Linux - Networking 4 05-12-2004 01:53 PM
SuSE 8.2 installation. Different computer, different road block. Thrifty Linux - Software 1 02-04-2004 12:59 PM
SuSE 8.2 installation. Different computer, different road block. Thrifty Linux - Software 0 02-04-2004 10:13 AM
teaching active directory w/o teaching network concept (possible???) Tafta General 4 01-21-2004 06:12 PM
Teaching Linux evilmrhenry Linux - General 5 11-14-2003 06:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration