LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-30-2006, 06:46 PM   #1
drum2jc
Member
 
Registered: Aug 2004
Location: Arroyo Grande, Ca
Distribution: Ubuntu 6.06
Posts: 49

Rep: Reputation: 15
shell script output to file


I'm writing a small shell script to add ftp users and create them a public html directory. all works fine except for when I try to write to a small html file:

this is my script:
Code:
#! /bin/bash

# get name
echo -n "Enter the new users name: "
read -e username

# create user and add them to ftp group
useradd $username
adduser $username ftpusers
passwd $username

# make them a public_html dir
mkdir /home/${username}
mkdir /home/${username}/public_html

# stick a default index page in it
"<h1>Default page for $username</h1><h5>You should change this file with your own content!</h5>" > /home/${username}/public_html/index.php

# give the user ownership and permissions
chown $username /home/${username}/public_html
chmod 755 /home/${username}/public_html

# hopefully everything went smoothly
# i'll add some error checking in later
echo "User $username created."
and this is the output when it's run
Code:
root@ubuntu:/home/admin/bin# ./new_ftp_user
Enter the new users name: anotheruser
Adding user `anotheruser' to group `ftpusers'...
Done.
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
./new_ftp_user: line 17: <h1>Default page for anotheruser</h1><h5>You should change this file with your own content!</h5>: No such file or directory
User anotheruser created.
can anyone help with that error i'm getting on line 17?
thanks,
chris

Last edited by drum2jc; 05-30-2006 at 06:50 PM.
 
Old 05-30-2006, 06:54 PM   #2
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
Quote:
# stick a default index page in it
"<h1>Default page for $username</h1><h5>You should change this file with your own content!</h5>" > /home/${username}/public_html/index.php

give the user ownership and permissions"
needs to be:

Code:
# stick a default index page in it
echo "<h1>Default page for $username</h1><h5>You should change this file with your own content!</h5>" > /home/${username}/public_html/index.php

# give the user ownership and permissions
You have to have the echo to tell the shell that you want the string sent somewhere (either your stout or a file in your case)
 
  


Reply



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
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 07:30 PM
Newbie No output from shell script nl1at Programming 2 04-04-2006 09:33 AM
Redirecting output of a shell script raj_deep2k1 Linux - General 2 01-20-2006 07:38 AM
shell script output redirection goral.j Programming 3 01-27-2005 05:34 AM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 03:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:27 PM.

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