run and make an executable file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting run and make an executable file
# 1  
Old 03-02-2009
run and make an executable file

as i said before i'm a beginner in shell programming and i have two questions:

how to run an executable file in shell scripts like for example let's say the file called "prog.exe", what's the shell command to run this file?

also how can i make the shell file an executable file (if it is "file.sh" i want it to be "file.exe")?
# 2  
Old 03-02-2009
Quote:
Originally Posted by _-_shadow_-_
as i said before i'm a beginner in shell programming and i have two questions:

how to run an executable file in shell scripts like for example let's say the file called "prog.exe", what's the shell command to run this file?

If prog.exe is in a directory in your $PATH:

Code:
prog.exe

If not:

Code:
/path/to/prog.exe

Quote:
also how can i make the shell file an executable file (if it is "file.sh" i want it to be "file.exe")?

Why would you want it to be file.exe? Just make file.sh executable:

Code:
chmod +x file.sh

# 3  
Old 03-02-2009
Quote:
Originally Posted by _-_shadow_-_
as i said before i'm a beginner in shell programming and i have two questions:

how to run an executable file win shell scripts like for example let's say the file called "prog.exe", what's the shell command to run this file?

also how can i make the shell file an executable file (if it is "file.sh" i want it to be "file.exe")?
The command to run the program is:

Code:
./prog.exe

if your current working directory is where the file lives. You can leave out the ./ if the executable is in your path. You can see your path by typing "echo $PATH" at the command line, and you can add directories to your path in your environment with the export command if you have a place you like to keep your scripts.

Also, you're thinking in "Windows," where file extensions tell the operating system what kind of file it is. Things don't work that way in Unix. The operating system knows whether a file is executable by looking at the executable flag. You could name it "cheese.etaothuaos" and it could still be an executable.

As a side note, you may have noticed the "shebang line" in other people's scripts. If you have a bash script, the first line of the file should be:

Code:
#!/usr/bin/env bash

If you have a Perl script, it should be:

Code:
#!/usr/bin/env perl

And so on. So when you run the program by typing ./file_name, the OS knows whether it should be running bash, korn shell, Perl, Python, or whatever. Of course, this changes once you're actually compiling your code into a binary file, like with C.
# 4  
Old 03-03-2009
well i want to be file.exe because i have linux and windows OS and i need the program to be executed in both also i want it to work forever and using SFU in windows is not that good

also i forget to mention in my question the path to the prog.exe is:

id address/path/to/prog.exe

i mean the program is not on the same computer it's on another computer connected via lan network and nfs
# 5  
Old 03-03-2009
as far as i know, unfortunately you cannot make one program to run equally in both. you will have to write separate programs for each OS. one for linux/unix, one for windows and your windows program will usually have to be created/compiled in the windows environment.

now if it is doing something like accessing a database, you can have one database sitting on say the unix box and have a program on each machine that can both access that one database. but again the program to do so would be separate for each OS.
# 6  
Old 03-03-2009
Quote:
Originally Posted by _-_shadow_-_
well i want to be file.exe because i have linux and windows OS and i need the program to be executed in both also i want it to work forever and using SFU in windows is not that good

also i forget to mention in my question the path to the prog.exe is:

id address/path/to/prog.exe

i mean the program is not on the same computer it's on another computer connected via lan network and nfs
That will not work. What kind of file is it? If it's a Perl or Python script, it's possible (depending on how it's written and what it does) to run it without changes on Unix and Windows, but you'd need to use the .pl or .py extension. If it's a compiled program written in, for example, C++, you'd need to compile it separately for Unix and Windows.

In any case, calling something a .exe is meaningless -- it doesn't actually do anything. If it's actually a .exe file compiled for Windows, then it lets Windows know that it's an executable file, but the actual format of the file has to also match what Windows expects a .exe to look like.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make a .exe file executable in Linux?

Dear all, I download a .exe file in my current folder called: ukbmd5.exe. I was told to run the command below: ukbmd5 ukb25278.enc to verify the integrity of the files that you have downloaded and the program ukbmd5 has been made available to assist with decrpying ukb25278.enc. while when I run... (1 Reply)
Discussion started by: forevertl
1 Replies

2. Shell Programming and Scripting

Bash script make itself executable

Is there a way to make this make itself executable? Thanks. :-) cat > somescript.sh << \EOF #!/bin/bash block_count=$(sudo tune2fs -l /dev/sda1 | awk '/^Block count:/ {print $NF}') reserved_block_count=$(sudo tune2fs -l /dev/sda1 | awk '/^Reserved block count:/ {print $NF}') perl -e... (4 Replies)
Discussion started by: drew77
4 Replies

3. UNIX for Beginners Questions & Answers

How to make a dynamically linked executable file?

So I have a file called queens.cc and I need to do the following: Compile and make a .o file while specifying that the compiler is to search /student/214/include for system include files. Use g++, link and load .o file to make a dynamically linked executable file called queens and to also... (1 Reply)
Discussion started by: steezuschrist96
1 Replies

4. Shell Programming and Scripting

Make multiple awk files into an executable

Hello everyone, The following are my input files. The following are my sequence of steps. Can someone please let me know about how to make these bunch of steps into a single script so that I start the script with 1.txt and 2.txt, after execution gives me the final... (11 Replies)
Discussion started by: jacobs.smith
11 Replies

5. Shell Programming and Scripting

Make script that run with argument if not run from configuration file argument

Hello, Is there any method thorugh which script can take argument if pass otherwise if argument doesn't pass then it takes the argument from the configuration file i.e I am workiing on a script which will run through crontab and the script will chekout the code ,zip and copy to the... (3 Replies)
Discussion started by: rohit22hamirpur
3 Replies

6. Shell Programming and Scripting

How to run my make file in Kornshell

Hello Forum Memebers, I have file with exension of .shsrc ie(startA.shsrc) .while iam trying to make ,its getting Ksh not found. file:startA.shsrc error:KSH not found the content about shell declaration in the korn shell is below. ... (3 Replies)
Discussion started by: rajkumar_g
3 Replies

7. Shell Programming and Scripting

Automatically select records from several files and then run a C executable file inside the script

Dear list its my first post and i would like to greet everyone What i would like to do is select records 7 and 11 from each files in a folder then run an executable inside the script for the selected parameters. The file format is something like this 7 100 200 7 100 250 7 100 300 ... (1 Reply)
Discussion started by: Gtolis
1 Replies

8. Shell Programming and Scripting

Unable to make script executable

Hello everybody, I'm unable to make my shell script an executable file. The details are as follows: PATH includes my $HOME/bin i.e. /rchome/rc1/bin HOME directory is /rchome/rc1 script name is prep_mig.sh permissions set are 755 It's executing if I give below command sh prep_mig.sh but... (4 Replies)
Discussion started by: jitu.keshwani
4 Replies

9. Solaris

How to make a script executable by all users?

I have a script in my home direcroty which upon execution gives the essential system information like memory,cpu etc and is currently owned by root:root. Now I want to see that every non root user will run this file and grab the reqired system info. I know this is some thing associated with chown... (2 Replies)
Discussion started by: chrs0302
2 Replies

10. UNIX for Dummies Questions & Answers

How do I make a cgi script World-executable

I'm trying to set up a form mail script on a website that when Submitted, a cgi script is executed and a perl translator (located in a secured and inaccessible folder) translates the script. After speaking to my hosting provider, I was told to "Telnet into the system and make the script... (2 Replies)
Discussion started by: tylerl
2 Replies
Login or Register to Ask a Question

Featured Tech Videos