Write an executable file in Unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Write an executable file in Unix
# 1  
Old 12-03-2009
Write an executable file in Unix

Hi,

I want to write an executable file in unix env to go to a particular path instead of always typing the long path cd /app/oracle/product/10.2.0/Db_1/scripts/prejib/sample.
I have tried with the below script in but not working . please help me


bash-3.00$ cat a.sh
#!/bin/sh
mypath=/app/oracle/product/10.2.0/Db_1/scripts/pressy/sample
echo $mypath
cd $mypath

bash-3.00$ chmod +x a.sh
bash-3.00$ sh a.sh
/app/oracle/product/10.2.0/Db_1/scripts/pressy/sample
bash-3.00$ pwd
/app/oracle/product/10.2.0/Db_1/scripts/pressy

After executing the file a.sh, I am in the same path only . How can I achieve that?
# 2  
Old 12-03-2009
you have to source that file..
that is run that as
Code:
. ./scriptname

# 3  
Old 12-03-2009
I am begginer to to UNIX. Can you please elaborate?
# 4  
Old 12-03-2009
When you execute a shell script it will fork a process and it will do all the operation in that sub shell. So the current working directory will be changed
only in the sub shell, not in the parent shell.

Code:
If you want to go to a particular path always, use alias.

Either use the following command in a current shell or use this in a ~/.bashrc 
if you want to use this alias always in all the shell.

$alias change='cd fullpath'

Once the alias is set, just type 'change' in the unix command line, the current working directory will be changed.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ksh: How to write the log file simultaneously when .sql file executes by UNIX process

Hello Team- we would like to implement an approach which has to write the log file simultaneously when .sql file is executing by Unix process. At present,it is writing the log file once the process is completed. I've tested the current process with the below approaches and none of them... (1 Reply)
Discussion started by: Hima_B
1 Replies

2. UNIX for Dummies Questions & Answers

Write terminal contents into a one file in UNIX

Hi guys, How to write terminal contents into a file in Unix operating system Actually I created GUI by using Gtk2-perl. I want to display data on GUI whatever the contents writing on terminal. So which command I have to use and where that command to be run I mean in shell script or Perl... (2 Replies)
Discussion started by: kiran425
2 Replies

3. Shell Programming and Scripting

Need to write a script to reformat a file in unix but not familiar with unix

unix script must do the fiollowing open a file containing comma delimited records > each record contains 10 fields > removes the 2nd field and use that same field containing fields 2 to 10 the original record after fprocessing should containing fields 1 and 3 a new erecord must be... (10 Replies)
Discussion started by: dwightja
10 Replies

4. Shell Programming and Scripting

unix executable file

Hi - How can I find out under sh whitch file is an unix executable file? Need it for an software inventory. Thanks in advance. Regards - Lazybaer (6 Replies)
Discussion started by: lazybaer
6 Replies

5. Shell Programming and Scripting

Please help to write a executable script for extracting some parts of a file

Hi All, I am very new in programming. I need some help. I have one input file like: Number of disabled taxa: 9 Loading mapping file: ncbi.map Load mapping: taxId2TaxLevel: 469951 --- Subsample reads (20%): 66680 of 334386 Processing: tree-from-summary Running tree-from-summary algorithm... (9 Replies)
Discussion started by: iammitra
9 Replies

6. UNIX for Advanced & Expert Users

How can i read a non text file in unix - ELF-64 executable object file - IA64

The binary file is ELF-64 executable object file - IA64. How i know that the source is Is there any comamnd in unix i can read these kind of files or use a thirty party software? Thanks for your help (8 Replies)
Discussion started by: alexcol
8 Replies

7. OS X (Apple)

What's The Easiest Route To Creating A Unix Executable File for Terminal?

I've seen the executable open in the application OmniOutliner, can I create an executable with this app? I'd like to be able to create the unix executable and insert it into terminal, but I'm not sure if the Omni app will allow me to create it. Any one have any ideas or possibly familiar with... (10 Replies)
Discussion started by: unimachead
10 Replies

8. Shell Programming and Scripting

Need to write a script in UNIX to find a file if another file exists

So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following. Search all the applications subdirectories for message.jar. If the message.jar file exists, I need to search the application directory for... (1 Reply)
Discussion started by: mmdawg
1 Replies

9. Filesystems, Disks and Memory

unix executable file problem on MAC OSX ??? please help

I've got this problem. My computers and external hard drives are converting many of my files to a Unix Executable File which has a grey terminal looking icon. I don't understand what is causing this to happen. It is happening to a large number of my image file of different formats and also... (1 Reply)
Discussion started by: chadb
1 Replies

10. UNIX for Dummies Questions & Answers

How to convert Unix executable file to Tiff

Hi, I know nothing about Unix. Recently received image files from a client. Mac sees it as a Unix executable file. How do I convert these files to Tiff? Thanks for helping. (1 Reply)
Discussion started by: Pet Teoh
1 Replies
Login or Register to Ask a Question