what is the DOS equivalent of alias command?


 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions what is the DOS equivalent of alias command?
# 8  
Old 04-07-2009
Quote:
Carlos, if you are trying to just change teh drives, you can simply type drive letter as in below...


C:\Documents and Settings\ilango>f:

F:\>e:

E:\>h:

H:\>c:
This approach will not work if you have a directory that have spaces in the path.
Code:
C:\Documents and Settings\All Users

To move from a mapped drive, for instance, to a profile directory you would need to use cd or chdir with the "/D" switch and encase the path with quotation marks.
Code:
chdir /D "C:\Documents and Settings\All Users"

Therefore my example gives the best way to accomplish the task and keep the typing to a minimum.
# 9  
Old 04-07-2009
Quote:
Originally Posted by ilan
Hello Milhan,

on top of what Pederabo has suggested.., the oter easy way to get working similar to aliases are using a set command..


C:\Documents and Settings\ilango\test>set dira=dir /A

C:\Documents and Settings\ilango\test>dir
Volume in drive C has no label.
Volume Serial Number is 548F-C2AD

Directory of C:\Documents and Settings\ilango\test

04/06/2009 12:13 PM <DIR> .
04/06/2009 12:13 PM <DIR> ..
04/06/2009 12:13 PM 4 normal.txt
1 File(s) 4 bytes
2 Dir(s) 6,269,435,904 bytes free

C:\Documents and Settings\ilango\test>%dira%
Volume in drive C has no label.
Volume Serial Number is 548F-C2AD

Directory of C:\Documents and Settings\ilango\test

04/06/2009 12:13 PM <DIR> .
04/06/2009 12:13 PM <DIR> ..
04/06/2009 12:13 PM 4 hidden.txt
04/06/2009 12:13 PM 4 normal.txt
2 File(s) 8 bytes
2 Dir(s) 6,269,403,136 bytes free

C:\Documents and Settings\ilango\test>


In teh above example, i made simiar to alias - dira to be executed as dir /A, only thing is you will have to use it with percentages.. as in %dira%

/ilan
Using the "set" command is not, in my opinion, a very efficient way for an alias to be created or used. Simply because of the way it needs to be typed on the command line or in a script. Also you can't use arguments with it.
Code:
C:> set dira="chdir /D $1"

C:> %dira% "C:\Documents and Settings\All Users"

The above command will not work. It would work if you only used the command with no argument capture but what would be the point? The whole idea of an alias is to be able to create a command with options and arguments without having to type the entire command every time you want to use it. In these examples we are using "dira." I count 4 characters. To use the "set" method you would be typing 6 characters to produce the same command if you were to use DosKey to produce the alias.
Code:
C:> set dira=chdir /D

C:> %dira% "C:\Documents and Settings\All Users"

The "set" command, in my opinion, should only be used to store variables.
# 10  
Old 04-07-2009
Carlos, your idea of using doskey is perfect. approach with set command is one of teh ways that we can achieve that..!!

on the chdir usage, i thought you are trying to switch drives often, i dien't realize that you switch to different directory paths.. overlook!

/ilan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert for command from DOS to SHELL

Well, this command has served me quite well under DOS for %%X in (*.txt) do COMMAND however in linux it just outputs: "./install.sh line 1: '%%x': not a valid identifier. Ideas ? Thanks in advance (2 Replies)
Discussion started by: pasc
2 Replies

2. UNIX for Dummies Questions & Answers

Create the equivalent of the command WC

hi all, i'm trying to do this exercise, i want to create a script that can substitute WC command in unix, can someone help me? (11 Replies)
Discussion started by: Marina2013
11 Replies

3. Windows & DOS: Issues & Discussions

DOS Equivalent of UNIX Command

Hi, The title of this post is a little vague but I couldn't think of what to call it. In Unix you can perform the following command ftp -v IPADDRESS <<END put FILE END In a DOS command prompt, is it possible to do the same kind of thing that the "<<END" does? So for example, ... (4 Replies)
Discussion started by: Ste_Moore01
4 Replies

4. AIX

smitty equivalent command line command

i know after you do something in smitty via the gui, you can click something in smitty that will show you how to do the same thing via the command line, (not using the gui) can anyone tell me how (2 Replies)
Discussion started by: asyed123
2 Replies

5. Windows & DOS: Issues & Discussions

dos/intel unix command equivalent

In Unix I can use command line to do a find for files older than so many days and remove them. I can also capture the date to see if its a saturday and do something different. Are there any dos/intel command line equivalent commands to do this on a windows 2003 server? This is from an... (6 Replies)
Discussion started by: MizzGail
6 Replies

6. Shell Programming and Scripting

Command for unix to dos conversion

Dear All Could you please advice how do we convert a unix file to dos I know one command,ux2dos, which somehow does not work to give desired output Inputs on this is appreciated Thanks, Suresh (3 Replies)
Discussion started by: sureshg_sampat
3 Replies

7. UNIX for Dummies Questions & Answers

Unix equivalent of DOS set

Hi all, what is the equivalent command of the DOS set that lists all the environment variable and their values? Xavier. (3 Replies)
Discussion started by: xxavier
3 Replies

8. UNIX for Advanced & Expert Users

Command equivalent to DOS mode for SCO 5.0.6

I need to set the serial port attributes to 9600,7,E,1 in order to read and write data to it from within a Foxpro program. Unfortunately there is no function in Foxpro to set the line attributes, only open. close read and write. Stty only works on the stdout and stdin in this release, and the... (3 Replies)
Discussion started by: jgt
3 Replies

9. UNIX for Dummies Questions & Answers

DOS command for ps

I have navigated every DOS and UNIX FAQ to find the DOS equivalent of the UNIX ps command (ps -f would be even better) but all listings of DOS<>UNIX commands do not have it (they all have the same basic commands listed). DOS must have a way of detecting running processes and TSRs. mem /c is the... (7 Replies)
Discussion started by: dancingfool
7 Replies

10. Windows & DOS: Issues & Discussions

SQL Spool equivalent command in DOS

This question maybe in the wrong category but I'm posting here due to urgency. In DOS is there a command to perform a similar function to spool command in SQL or Script command in UNIX? I want to print all command line output to a file but I don't want to use the echo command for each line. ... (2 Replies)
Discussion started by: stevefox
2 Replies
Login or Register to Ask a Question