LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-02-2017, 05:16 AM   #1
ormargol
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Rep: Reputation: Disabled
File Not Found When running binary from .sh file


I'm using cygwin on my windows machine.
I have cpp file that open another file and read it.
on the same directory where the cpp and its builded exe exists,
I've written script.sh which contains the running of the exe file.
When I'm runnung the exe file direct it works, but when it runs from the script.sh it says that the neede file to be opened and read, is not found!

I've checked the pwd and its the same on both running.
What can cause that?
 
Old 03-02-2017, 05:25 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you ought to show your script. The problem is in line #34
http://www.linuxquestions.org/questi...gs-4175464257/
 
Old 03-02-2017, 06:00 AM   #3
ormargol
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Here is the code

Code:
	if (optind < argc) {
			strcpy(BIN_FILE,argv[optind++]);
			//make sure the executable exists
			rc=access( BIN_FILE, F_OK );
			if ((  rc == -1 )) {
				rc = errno;
				myprintf("Value of errno: %d\n", errno);
				myprintf("Error opening file: %s\n", strerror( rc ));
				myprintf("%s\n", BIN_FILE);
				exit(AR_EXIT_FAILURE);
			}
			//Separate the filename and dirname C is unbelievable a simple dirname/basename call destroying its in therefor forcing us to make a duplicate first :-(
			char *dirc, *basec;
			dirc = strdup(BIN_FILE);
			basec = strdup(BIN_FILE);
		    strcpy(BIN_FILE_DIR,dirname( dirc ));
		    strcpy(BIN_FILE_NAME,basename( basec ));

	}
Note that it worked when I'm just running the binary.
When I'm calling it from script.sh it dont works.
 
Old 03-02-2017, 10:03 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by ormargol View Post
When I'm calling it from script.sh it dont works.
That still doesn't help...you need to give us the script so we know how the program is being called, and the actual output when you try to run it.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo entry for running binary file deepak_message Linux - Server 1 06-12-2012 01:13 AM
Help: Opening GenICs binary file, writing to binary file for GADGET-2 (in C) parallax147 Programming 0 10-05-2010 11:06 AM
scp truncate text file busy - copying file is not a running binary jetberrocal Linux - Server 3 06-24-2010 03:56 PM
Binary file cannot be found. dmuffet Programming 3 01-30-2010 01:14 PM
Problem running execute binary file zekko Linux - General 18 08-08-2003 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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