Regarding "How to make a script as a command?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Regarding "How to make a script as a command?
# 1  
Old 10-18-2007
Bug Regarding "How to make a script as a command?

Hi unix_guru(s),

How to make a shell script into a normal unix command?.

I'm always using shell to run a script(like $ksh demo.ksh).

I don't want to use this ksh at all time.

The script sholud run if i am typing as "demo" instead of typing "ksh demo.ksh"

Please, give me that trick.
# 2  
Old 10-18-2007
Rule 1.

make the script executable by

Code:
chmod +x script

Rule 2.

have the name of the interpretor in the first line of your script as follows

Code:
#!/bin/ksh

# 3  
Old 10-19-2007
Quote:
The script sholud run if i am typing as "demo" instead of typing "ksh demo.ksh"
Do what porter suggested +

3. Put the directory in which you keep the scripts in the default PATH
and if you really want to execute it like $ demo not like $ demo.sh

4. make an alias for it in .ksh_profile
Code:
alias demo='demo.sh'

all the best,
v
# 4  
Old 10-19-2007
Quote:
4. make an alias for it in .ksh_profile
Code:

alias demo='demo.sh'
when the script is added to the $PATH
just renaming it would do
just ' checkProcess ' would do instead of ' checkProcess.ksh '


Make sure the she-bang line is added to the script
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Piping the "script" command through the logger command.

I use the snippet below in /etc/profile on RHEL Linux to capture command line logging and it all works well and good. Now I'd like to pipe the same output from script through the logger command so it all gets logged to syslog. The only additional code I've added is in bold below (|... (4 Replies)
Discussion started by: woodson2
4 Replies

4. Shell Programming and Scripting

Problem with "make" command in Linux

Hi all, I downloaded an external program and extracted all the files to a folder. they have a make file which I have to run. But when I run make file I get an error g++ -O2 -c pgm.cpp make: g++: Command not found make: *** Error 127 When I checked the list of GCC I get this binf-01... (14 Replies)
Discussion started by: kaav06
14 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Make scipt except from "Y","y" and "yes" to take [Enter] as being "yes"

This is the script: #!/bin/sh if ; then rm -rf /usr/share/WallpaperChanger; fi if ; then rm -rf /usr/bin/wallch; fi; if ; then rm -rf /usr/share/applications/wallch.desktop; fi if ; then rm -rf /usr/share/doc/wallch; fi if ; then rm -rf /usr/share/man/man1/wallch.1.gz; fi echo "Delete... (4 Replies)
Discussion started by: hakermania
4 Replies

7. Shell Programming and Scripting

How to make a script run for a maximum of "x" number of hours only

How to make a script run for a maximum of "x" number of hours only (7 Replies)
Discussion started by: ScriptDummy
7 Replies

8. Shell Programming and Scripting

Q: Recording shell script screen output using "script" command ?

Hello, I need to capture everything showed on a screen by a shell script which needs user interaction. The shell script performs commads such as rsh so normal redirection to a file does not work. I know there is a special unix command call "script" which records screen session but the... (4 Replies)
Discussion started by: lalfonso.gomez
4 Replies

9. Programming

how could i make a program mixed with many "|", "<" and ">"

I have written following code to do: ls -l | wc -w, it works: but when there are not only a single "|", if there are more such as: ls -l | sort -r | sort | sort -r, This program does not work, i want to know how could i deal with it when there are more "|", another situation is that, if it mixes... (2 Replies)
Discussion started by: strugglingman
2 Replies

10. UNIX for Dummies Questions & Answers

"./cofigure" and "make" turmoil

I am a Unix newbie and I downloaded some X11 programs. I have gcc, but I cannot compile the files. I NEED HELP!!!! :confused: (16 Replies)
Discussion started by: gnerd
16 Replies
Login or Register to Ask a Question