LinuxQuestions.org
Review your favorite Linux distribution.
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 03-15-2013, 02:26 PM   #16
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,388

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553

Quote:
Originally Posted by danielbmartin View Post
When I enter /home/daniel/Desktop/LQfiles/dbm684.bin the result is bash: /home/daniel/Desktop/LQfiles/dbm684.bin: Permission denied
You need give execute permission for the file (chmod +x /home/daniel/Desktop/LQfiles/dbm684.bin).

Quote:
It's unclear what benefit is obtained by the #!/bin/bash
The benefit is that the person/program executing the file doesn't need to know which interpreter to use because it's encoded in the file itself.
 
Old 03-15-2013, 04:22 PM   #17
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 592

Rep: Reputation: 140Reputation: 140
Quote:
... so your Path= and mine are not equivalent.
I was on the assumption that you start the program from the directory where the datafiles are.
While you are on the assumption that the data files are in the same directory as the script.
I assumed the OP's shell doesn't support the direction operator and tried to find substitutes for it.
offtopic I just installed Centos for RHCE qualification. What a terrible installer it has if you don't want a standard install.
 
Old 03-15-2013, 04:40 PM   #18
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,700

Rep: Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564
Quote:
Originally Posted by whizje View Post
While you are on the assumption that the data files are in the same directory as the script.
Not an assumption, it is a requirement (unless you change the file definitions in the code).

Daniel B. Martin
 
Old 03-15-2013, 05:08 PM   #19
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 592

Rep: Reputation: 140Reputation: 140
Quote:
Not an assumption, it is a requirement (unless you change the file definitions in the code).
Ok do you have a alternative for the redirection operator.
 
Old 03-16-2013, 11:10 AM   #20
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,700

Rep: Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564
Quote:
Originally Posted by whizje View Post
Ok do you have a alternative for the redirection operator.
The file identifier for my program is /home/daniel/Desktop/LQfiles/dbm678.bin
The input files, work files, and the output file are all located in the same folder and with similar file names.
All of the file names start with /home/daniel/Desktop/LQfiles/dbm678
This code ...
Code:
Path=$(cut -d'.' -f1 <<< ${0})
... produces this desirable result ...
Code:
/home/daniel/Desktop/LQfiles/dbm678
... but you could hard code it thusly ...
Code:
Path="/home/daniel/Desktop/LQfiles/dbm678"
The output file is /home/daniel/Desktop/LQfiles/dbm678out.txt

The input files are ...
Code:
/home/daniel/Desktop/LQfiles/dbm678inp1.txt
/home/daniel/Desktop/LQfiles/dbm678inp2.txt
/home/daniel/Desktop/LQfiles/dbm678inp3.txt
/home/daniel/Desktop/LQfiles/dbm678inp4.txt
/home/daniel/Desktop/LQfiles/dbm678inp5.txt
... and the corresponding work files are ...
Code:
/home/daniel/Desktop/LQfiles/dbm678w1.txt
/home/daniel/Desktop/LQfiles/dbm678w2.txt
/home/daniel/Desktop/LQfiles/dbm678w3.txt
/home/daniel/Desktop/LQfiles/dbm678w4.txt
/home/daniel/Desktop/LQfiles/dbm678w5.txt
The OP would have to substitute appropriate file identifiers for his computer.
They might be of the form ...
Code:
/home/cheah/What/Ever/dbm678.bin
 ... and ...
/home/cheah/What/Ever/dbm678inp1.txt
 ... and ...
/home/cheah/What/Ever/dbm678w1.txt
 ... and ...
/home/cheah/What/Ever/dbm678out.txt
If there are 12 input files he would need input file identifiers numbered 1 through 12, and corresponding work files numbered 1 through 12.

Daniel B. Martin

Last edited by danielbmartin; 03-16-2013 at 11:19 AM. Reason: Clarification
 
Old 03-16-2013, 02:28 PM   #21
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 592

Rep: Reputation: 140Reputation: 140
Code:
Path=$(cut -d'.' -f1 <<< ${0})
alternative
Path=$(readlink -f $0)
 
1 members found this post helpful.
Old 03-16-2013, 02:35 PM   #22
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,700

Rep: Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564Reputation: 564
Quote:
Originally Posted by whizje View Post
Code:
Path=$(cut -d'.' -f1 <<< ${0})
alternative
Path=$(readlink -f $0)
Your suggested alternative is not equivalent.
However, this is ...
Code:
Path=$(readlink -f $0 | cut -d'.' -f1)
... and I will use it henceforth.

Perhaps this change is the only obstacle preventing OP from using my program.

Daniel B. Martin
 
1 members found this post helpful.
  


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
Join Linux Server With Multiple Domains ? prayingtosky Linux - Newbie 1 01-13-2011 09:05 PM
[SOLVED] Viewing Multiple Files with the less command Hi_This_is_Dev Linux - General 3 04-14-2010 06:02 PM
Command to join text files with headers chips11 Linux - Newbie 3 11-19-2008 04:43 PM
Unable to join domain using Net Join command in FC3 client jeb083079 Linux - Networking 9 07-30-2007 03:41 AM
join multiple files onewhoknows Linux - Software 10 06-01-2004 07:51 PM

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

All times are GMT -5. The time now is 08:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration