LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 12-02-2002, 01:34 PM   #1
d3funct
Member
 
Registered: Jun 2001
Location: Centralia, WA
Posts: 274

Rep: Reputation: 31
'cat' not allowing absolute filenames when piped to 'cut'


Hello,

I'm writing a script to create a filesystem layout on an AIX 5.1L Regatta using LVM. In this script I'm using a "for" loop to 'cat' a file and retrieve the filesystem name from the fourth field. The file I'm reading from looks like this:

VGName LVName LogName FileSystem LVSize

My forloop for the Filesystem looks like this:

for l in `cat layout.txt |cut -d" " -f4`
do FSN=$l
export $FSN
done


When I run the script it errors saying:
./Srwds.ksh[24]: /u02_01: is not an identifier

I know the slash (/) is the problem because if I remove them I do not get an error unless the filesystem I'm creating is something like opt/apps/somefile.

My question is how do I get around this? I need to create filesystems with absolute pathnames, and there are so many to create that putting them in a file and running the script is the best way to do it. Thanks for any and all suggestions.
 
Old 12-02-2002, 03:02 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Why are you calling export on the filesystem names? I think the export you are calling is the shell export for exporing shell variables. The filesystem names read from the file are not valid shell variables, so you are getting the error.
 
Old 12-02-2002, 04:56 PM   #3
d3funct
Member
 
Registered: Jun 2001
Location: Centralia, WA
Posts: 274

Original Poster
Rep: Reputation: 31
I'm exporting FSN={the filesystem name} (i.e., export FSN=/opt/games). I accidently put $FSN instead of just FSN for my variable name.
 
Old 12-02-2002, 10:08 PM   #4
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
How many lines are there in your layout.txt? more than one?

for filesystem in `awk '{print $4}' layout.txt`; do
export FSN=$filesystem
done
 
Old 12-03-2002, 09:52 AM   #5
d3funct
Member
 
Registered: Jun 2001
Location: Centralia, WA
Posts: 274

Original Poster
Rep: Reputation: 31
Moses,

The file has about 15 lines that look like this:

u02rlvg u02rllv u02rllog /u02_01 8
u02rbvg u02rblv u02rblog /u02_02 8

etc....

What I want to do is use these entries to define my variables which will be put into commands like mklv, crfs and the like. I've also begun trying to write a perl script to do this because in the near future I'll be working with many more (30+) filesystems at a time.
 
Old 12-03-2002, 10:04 AM   #6
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Do it in Perl, if the above awk script doesn't work for you.
 
Old 12-06-2002, 02:36 AM   #7
treebeard
LQ Newbie
 
Registered: Jun 2002
Location: Bucharest, Romania
Distribution: Slackware
Posts: 16

Rep: Reputation: 0
in the initial shell script, you should've used 'export FSN' instead of 'export $FSN'
 
  


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
PHP Shell Script - Read piped text dlublink Linux - Software 3 08-13-2005 01:57 PM
floppy and CD disk filenames cut off Cinematography Linux - Software 13 05-27-2005 03:56 PM
Apache piped logs - split-logfile - zero size files alex_fittyfives Linux - Enterprise 0 08-26-2004 07:04 AM
Problem executing this piped command: JAVA randomx Programming 1 07-16-2004 07:39 PM
How to redirect standard output of piped command to log file andrewstr Linux - General 10 02-04-2004 02:07 PM

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

All times are GMT -5. The time now is 12:52 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