Open a file from within a Bourne shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Open a file from within a Bourne shell Script
# 1  
Old 02-14-2012
Open a file from within a Bourne shell Script

I am suppose to make a program that cuts the extension off of a file. It uses that .ext to decide which program needs to be used to open the file. This only finds the name of the program from a list of programs I made. My problem is when it has the name of the program it needs to use, how can I make the program open the file with code in the script.

It is okay to assume that files will only have one period.

Code so far:
Code:
#!/usr/bin/bash -x

FNAME=$1
export FNAME
FILE_EXTENSION=`echo $FNAME | cut -f2 -d "."`

a=`grep  $FILE_EXTENSION dorc.sh`
echo $a
PROG=`echo $a | cut  -f5 -d "/"`


Last edited by dordrix; 02-14-2012 at 08:56 PM..
# 2  
Old 02-14-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to zaxxon For This Post:
# 3  
Old 02-14-2012
Quote:
Originally Posted by zaxxon
Bumping up posts or double posting is not permitted in these forums.


You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Yeah, sorry I tried to delete the other one, but there isn't a delete option. I thought that the post was more relevant to shell forum after I posted in that other one.
# 4  
Old 02-15-2012
Ok - I move it there then. If you have any issues like this, contact a moderator please. I will remove the warning/reminder for the double post.
Ah I see I missed to close this thread and you got an answer in the other one, nvm. Setting a link to the other one and closing this here.

https://www.unix.com/shell-programmin...in-script.html

Last edited by zaxxon; 02-15-2012 at 03:42 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Open and edit a file using a shell script

Hello Folks, I have a file named as date.dat present at /tmp/abc location which has following data - 20161030,20161031,20161101 I need to remove this line and replace it with something like below - $param1,$param2,$param3 Param1, Param2 and param3 stores the date based on some calculation in... (1 Reply)
Discussion started by: ektubbe
1 Replies

2. Homework & Coursework Questions

New user needs help with bourne shell script

This is my question, below the question is the template Write and execute a Bourne shell script called homework that will From within the script, create three background processes: a) (2 points) one that saves a long listing of your hidden files to a file named hiddenlist b) (2 points) ... (4 Replies)
Discussion started by: luislozoya
4 Replies

3. Shell Programming and Scripting

To open a file in shell script.

Hi Guys, I want to open a file in shell script and copy the last file of the line for display. Can anyone help?? (3 Replies)
Discussion started by: Karthick N
3 Replies

4. Shell Programming and Scripting

help with bourne shell script

Attempting to write a script to eventually notify me via email for when there is packetloss across the backbone. I am looking for values greater than 0% in the mtr field. #!/bin/sh target=www.google.com date +"%D"_"%T" >> /home/rich/mtr.log echo "----------------------------------------" >>... (1 Reply)
Discussion started by: closedown
1 Replies

5. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

6. Shell Programming and Scripting

cd from a Bourne Shell Script - Please Help

Dear Bourne Shell Expert, I am trying to change the current working directory from within a Bourne Shell script. Simply enough i thought ! As I am sure you are well aware, Inside the script i echo `pwd` and it seems ok, but the shell spawns another shell to execute this and as such, when my... (10 Replies)
Discussion started by: fawqati
10 Replies

7. Shell Programming and Scripting

open a file in shell script

Hi all How to open a file in a unix shell program. also i want it open for an hour and run independent of other jobs. pls help me solve this issue... (2 Replies)
Discussion started by: bankpro
2 Replies

8. UNIX for Dummies Questions & Answers

Bourne Shell Script

Hello, I'm throwing this out there as a novice to the Unix world...I've been working on a project that requires me to ouput (using the echo command) a list of names in a single column format, but the problem is the input is in row format followed by a blank space...If anyone could give me a... (2 Replies)
Discussion started by: dmhonor914
2 Replies

9. Shell Programming and Scripting

bourne shell script

Hi all, Can somebody answer the following query Thanks, Srinivas A shell program that takes one or any number of file directory names as input; sorts the directories given as parameters jointly in the ascending or decending order of choice For EX : dips abc etc desc will sort the files... (2 Replies)
Discussion started by: psrinivas
2 Replies

10. UNIX for Advanced & Expert Users

Bourne shell script need help please ?

i have this assignment.. and i mad this script but there is something wrong with it.. if anyone can tell me.. watz going on... i would appreciate it.. tHnX in advance.. count=1 val=$2 op=$1 ans=0 if then if then while do ... (7 Replies)
Discussion started by: dezithug
7 Replies
Login or Register to Ask a Question