mac command line command not found - macos

Ok so I've been trying to run some things from the command line and I'm having a 'permission denied' problem and then when I 'sudo ./(file.c' I get a 'command not found'. It's weird because other .c files in the same directory work ok.
I've downloaded and installed Xcode and command line tools. Also, I have #include some other things that are also in the same directory.
When I echo $PATH I'm getting this output:
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Thanks for any help that could be provided!

You're running sudo ./file.c but file.c looks like the name of a source code file which would usually not be executable. Probably the problem you're having is that you're trying to run something which cannot be run. If you really want to force the computer to run it, you can do chmod +x file.c before trying to run it. But if it is indeed C source code, it won't do anything useful.

Related

mingw5.4 : cannot open output file /home/user1/test.o: No such file or directory

I am building my test.c using mingw5.4 using command:
/software/mingw5.4/bin//x86_64-w64-mingw32-gcc test.cxx -o /home/user1/test.o
But I am getting following error:
c:/cygwin64_new/home/admin/software/mingw5.4/bin/../lib/gcc/x86_64-w64-mingw32/5.4.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot open output file /home/user1/test.o: No such file or directory
If I use version mingw4.8.3 the same file is compiling fine.
/usr/bin/x86_64-w64-mingw32-gcc test.cxx -o /home/user1/test.o
If anybody know reason of error in case of version mingw5.4 please let me know.
LOL. I've done that. There is a command called test on *nix systems. Some shells have it built in (for speed). Try running ./test or text.exe or call the executable something else.

MinGW where is "cat" and "ls"? Simple commands are missing

Performed a fresh install of mingw. here's exactly what i did:
mingw-get-setup.exe
installed to i:\mingw
using the GUI selected the following packages:
mingw-developer-toolkit
mingw-gcc-g++
msys-base
setup fstab:
i:
cd \mingw\msys\1.0\etc
copy fstab.sample fstab
change c:/mingw to i:\mingw
comment out perl
add to PATH:
i:\mingw\bin;i:\mingw\msys\1.0\bin
various things work, but there's no "cat" nor "ls". Looking inside i:\mingw these files just aren't there.
tried the shell:
i:\MinGW\msys\1.0\msys.bat
eg which gcc gives:
$ which gcc
/bin/which: line 47: ls: command not found
/bin/which: line 47: ls: command not found
/mingw/bin/gcc
any idea what package is missing.
thanks.
I had to set path=%path%;c:\MinGW\msys\1.0\bin\
turned out the file, coreutils-5.97-3-msys-1.0.13-bin.tar.lzma was corrupt.
Looks like the mingw-get does not check for errors when it downloads. :-(

Batch script calls a Bash script but output file does not populate

I have a batch script that looks like this
# echo off
c:/cygwin/bin/bash -li each_sec_extract.bash c:/iperfprocess/sprint/file1.txt > c:/iperfprocess/sprintbashed/file1.txt each_sec_extract.bash c:/iperfprocess/sprint/file2.txt > c:/iperfprocess/sprintbashed/file2.txt
When i run this as is, the CYGWIN bash terminal pops up and I can observe the script producing the output I want on the screen, however, when I go to the directory where the file should be located (c:/iperfprocess/sprintbashed/), I am greeted by an empty text file. When i enter instructions from the CMD line manually, I receive the same result. However, when I run the instruction directly from CYGWIN, it works flawlessly. The part that frustrates me the most, this script used to work fine, then I started getting SED: permission denied errors which forced me to run bash.exe in administrative mode.
Any ideas about what might be happening or what a solution may be? Thank you in advance for any and all help provided.
Is this any different?
#echo off
c:/cygwin/bin/bash -li each_sec_extract.bash c:/iperfprocess/sprint/file1.txt > c:/iperfprocess/sprintbashed/file1.txt
c:/cygwin/bin/bash -li each_sec_extract.bash c:/iperfprocess/sprint/file2.txt > c:/iperfprocess/sprintbashed/file2.txt
The SED: Permission error was the underlying cause of the empty output files that was experienced. Running bash in administrative privileges was only a work around that didn't fix the actual problem. For some reason, sed.exe became corrupt. The solution was comprised of downloading UnxUtils from http://sourceforge.net/projects/unxutils/?source=dlp and replacing the sed.exe found from CYGWIN/bin/ and replacing it with the one in the UnxUtils zip file.
I ran my script after these steps and everything worked perfectly as it did prior to the issue.

Running an executable in Mac Terminal

I just made a .c file and compiled it with gcc in the terminal on OS X 10.8.2.
My syntax was gcc -o <filename> <sourcefile> and that was fine. Now I see I have an executable and file <filename> tells me as such, but I'm not sure how to actually run it beside double clicking the icon, /lame. When I try running the executable by just typing I get command not found, but I thought it was executable...?
Thank you.
EDIT: I"m so stupid, it was just open <filename>
Unix will only run commands if they are available on the system path, as you can view by the $PATH variable
echo $PATH
Executables located in directories that are not on the path cannot be run unless you specify their full location. So in your case, assuming the executable is in the current directory you are working with, then you can execute it as such
./my-exec
Where my-exec is the name of your program.
To run an executable in mac
1). Move to the path of the file:
cd/PATH_OF_THE_FILE
2). Run the following command to set the file's executable bit using the chmod command:
chmod +x ./NAME_OF_THE_FILE
3). Run the following command to execute the file:
./NAME_OF_THE_FILE
Once you have run these commands, going ahead you just have to run command 3, while in the files path.

binary file not executing with double click on osx

I've compiled an executable from someone else's source code but it will only run if I launch a shell and cd into the right directory and then to ./executable.name. But if i double click the executable I get this error 'There is no application set to open the document'.
Ive tried to do sudo chmod -x executable.name but that doesn't do it.
Does anyone recognise this problem?
I have found the problem was that there was a . in the file name that confused the system. Ive removed the . and it runs fine now

Resources