A very simple script, but alias won't work


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A very simple script, but alias won't work
# 8  
Old 05-21-2010
Defeats the purpose? I'm suggesting your store the alias directive in your .profile, .cshrc or .whatever file... This way it's in place for the entire session. I'm not suggesting you manually declare the alias each time... Smilie

Meanwhile, is it possible you don't have write permissions to the target file?
# 9  
Old 05-21-2010
Please output cshrc file
Code:
cat home/youruser/.cshrc

# 10  
Old 05-21-2010
Quote:
Originally Posted by curleb
Defeats the purpose? I'm suggesting your store the alias directive in your .profile, .cshrc or .whatever file... This way it's in place for the entire session. I'm not suggesting you manually declare the alias each time... Smilie

Meanwhile, is it possible you don't have write permissions to the target file?
Target file ? You mean myfile.log etc. Yes, I do have permission to those files.

Putting these aliases in .cshrc file is a great suggestion and it should work as I do have whole bunch of aliases set in my .cshrc file but then I can't pass the parameter if I set the alias as "vi $1.log".
Any idea why it will not work from a stand alone script like this.

Last edited by sssccc; 05-21-2010 at 01:59 PM..
# 11  
Old 05-21-2010
One of my favorite quotes:
Quote:
I'm not a burning bush...I can only make suggestions.
Best to focus on what works, since this is only impairing your need to assign aliases. If it would apply to other functionality...or if it makes itself known in other ways, we can tackle it there.

HTH

Epilogue:

Sorry...missed the part re passing args and making this alias dynamic to your session: http://docstore.mik.ua/orelly/unix/upt/ch10_03.htm

Last edited by curleb; 05-21-2010 at 02:00 PM..
# 12  
Old 05-21-2010
Quote:
Originally Posted by ygemici
Please output cshrc file
Code:
cat home/youruser/.cshrc

Do you want me to post my .cshrc file here ?
# 13  
Old 05-21-2010
why not...
# 14  
Old 05-21-2010
Quote:
Originally Posted by curleb
One of my favorite quotes:


Best to focus on what works, since this is only impairing your need to assign aliases. If it would apply to other functionality...or if it makes itself known in other ways, we can tackle it there.

HTH

Epilogue:

Sorry...missed the part re passing args and making this alias dynamic to your session: [Chapter 10] 10.3 C Shell Aliases with Command-Line Arguments
Thanks curleb. That link provided some very useful info for me. However, let me redefine what I am trying to accomplish.

1. Set up a c shell script named (let us say al) with the following three aliases in it:
alias s "vi $1.csv"
alias t "vi $1.txt"
alias l "vi $1.log"
2. Then run the script as al myfile.
3. This will set the 3 aliases pointing to myfile.
4. I just type s, l or t depending on which myfile.? I want to edit.
5. Then after few hours I change the file by issuing al yourfile.
6. Now all three aliases point to yourfile.? and I can use s, l or t pointing to yourfile.?.

I might do that several times in a session. I type the name of the file only once when running the script and after that I type only s, l or t depending on which file I want to edit.

If I put the alias in .cshrc file by putting \!$ in the alias definition, I still type the full filename everytime I use the alias, right ? That is what I want to avoid.

Hope that clarifies the problem.

---------- Post updated at 01:33 PM ---------- Previous update was at 01:20 PM ----------

Quote:
Originally Posted by curleb
why not...
Here is my .cshrc.


#################################################################
#
# .cshrc file for idnadhoc domain Version 1.0 3/2004
#
#################################################################
#echo " *** starting logon script .cshrc ***"
# Set default UNIX editor to vi
setenv EDITOR vi
# Set Paths for software
set path= ( /idn/app/bin /xxxx/xxxxxxxx/bin /usr/bin /usr/ucb /usr/sbin /usr/openwin/bin /usr/dt/bin . )
setenv LD_LIBRARY_PATH ~/lib:/idn/app/lib:/lib:/usr/openwin/lib:/usr/dt/lib:/usr/lib:
setenv PGPPATH $HOME/pgp
setenv GZIP "-8v --name"
#setenv LD_LIBRARY_PATH_64=/xxxx/xxxxxxxxx/lib:$LD_LIBRARY_PATH_64
#export PATH=/xxxx/xxxxxxxxx/lib:/usr/lib:$PATH

# Host Name Set-up
switch (`hostname`)
case sppmd006:
setenv HOST "idnadhoc"
breaksw
case sppmd007:
setenv HOST "idnoae"
breaksw
default:
setenv HOST `hostname`
breaksw
endsw
if ($?prompt == 0) exit
# Set backspace key is commented out due to issues with SAS system and X commands
# stty erase ^h
# Standard UNIX options
set prompt="$HOST":"`pwd`> "
set history=999
set ignoreeof
set savehist=0
set noclobber
if ( $?prompt ) then
stty werase '^?'
stty erase '^h'
endif
echo " * starting alias section *"
# Standard Aliases
alias cd 'cd \!*;echo $cwd;set prompt="$HOST":"`pwd`> " '
alias md 'mkdir'
alias cp 'cp -i'
alias mv 'mv -i'
alias rm 'rm -i'
alias pwd 'echo $cwd'
alias del 'rm -i'
alias p 'ps -aux | more'
# User Custom Aliases
# Use alias 'ucb <command>' to get ucb version
# aliases for all shells
#junk file(s) to the trashcan:
alias can 'mv\!* ~/.trashcan'
alias cd 'cd \!*;echo $cwd;set prompt="$cwd \! " '
alias cp 'cp -ip'
alias mv 'mv -i'
alias mail 'cd /var/mail'
alias pwd 'echo $cwd'
alias cls 'clear'
alias h 'history \!* | head -39 | more'
alias clear
alias m more
#alias dir 'ls -la'
#alias dirt 'ls -lad'
alias la 'ls -a'
alias ll 'ls -la'
alias lo logout
alias bye logout
alias edit textedit
alias resize /usr/bin/X11/resize
alias land 'enscript -r -fTimes-Roman9 \!*'
alias lwf '/usr/lib/lp/postscript/postprint -p l -s 9 -l 51 \!* | lp -'
alias lpman 'troff -man \!* | /usr/lib/lp/postscript/dpost | lp'
alias ucb '/usr/ucb/\!*'
alias Ipp 'cd /intl/ipp/projects'
alias tp 'ls -lt | head -20'
alias compresstxt "compress `find . -type f -name '*.txt' -print`"
alias dir 'ls -la'
alias dirt 'ls -lad'
alias dird 'ls -al | egrep ''^d'' '
echo " *** finished logon script .cshrc ***"
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK... (3 Replies)
Discussion started by: yelirt5
3 Replies

2. Shell Programming and Scripting

Nested double quotes won't work in my bash script?

In a bash script I have: LSCMD="find /project/media/ -mindepth 2 -maxdepth 2 -name \"files*pkg\"" ALL_PACKAGES=$( $LSCMD | sort 2>/dev/null) But I get nothing returned. It's just all blank. If I run the find command in a terminal, I get dozens of hits. I figure it's the way how I'm... (3 Replies)
Discussion started by: superbbrr
3 Replies

3. BSD

Install cd won't work

Hi! I'm sure that somebody here installed freeBSD from a download of a virtual disc (.iso). But I made 5 downloads of 5 differents freeBSD installation (and no one has worked).Can somebody tell me where to download and how (if needed) to prepare the cd? (8 Replies)
Discussion started by: maxum
8 Replies

4. Shell Programming and Scripting

Crontab - wrote Simple Script but i cant work out how to play it at a certain time.

Hi everyone. Silly might be silly be I'm still new to bash. I'm trying to make an Alarm Clock for in the morning using my laptop i have wrote this Simple Script but i cant work out how to play it at a certain time. #!/bin/bash cd /home/josh/Music/Bruno_Mars/Hooligans/ cvlc... (8 Replies)
Discussion started by: jtsmith90
8 Replies

5. Shell Programming and Scripting

created a .alias, but they won't take (ksh)

I login with a common username, and have no access to the different login scripts for my personalizations. So for a while, I would hobble on over to a directory I made for myself, and then bring in my alias file where I would fix my backspace, create a few aliases, etc.: $ ./.alias $ Now... (4 Replies)
Discussion started by: hindesite
4 Replies

6. UNIX for Dummies Questions & Answers

sed won't work

Hi All, can anybody tell me what's wrong with this code? # SEARCH replaced by REPLACE #!/bin/bash SEARCH="95$$ 0 t" REPLACE="95$$ 1 t" for I in `ls *000.inp | cut -c-12`; do echo $I sed 's/$SEARCH/$REPLACE/' ${I}-000.inp > ${I}-100.inp done It don't replace the string... (5 Replies)
Discussion started by: f_o_555
5 Replies

7. Shell Programming and Scripting

Global alias does not work in shell script

Hi Linux Set up - alias ls='ls -l' Then run script #! /bin/ksh sub() { ls } sub Is there any way to get it working. I don't want to define alias inside of the program Thank you (2 Replies)
Discussion started by: zam
2 Replies

8. UNIX for Dummies Questions & Answers

tip: Simple script won't run in cygwin - vim editor involved

I ran into this issue and thanks to various postings in various forums, was able to figure out the solution but didn't see one posting that laid the whole issue out cleanly. So thought the following might help others ... ------------------------------------------------------------------------... (2 Replies)
Discussion started by: oxysep
2 Replies

9. UNIX for Dummies Questions & Answers

Simple cron job won't work

I have a script in a directory -say users/me/test/ It looks like this: # "bkup" - copies specified files to the user's ~/Backup # directory after checking for name conflicts. a=$(date +%T) cp $1 ~/test/Backup/$1.$a It copies file.txt from current directory and timestamps the name of it of... (4 Replies)
Discussion started by: coregan
4 Replies

10. UNIX for Dummies Questions & Answers

why won't this Work?

hey programmers! 1-why won't gcc accept as an argument? i tried the recommendations on the man page of getch(),..etc. nothing worked. 2-why it won't see <iostream> && <fstream> even if i implemented the function as follow std::cout<<"..etc"<<endl; 3-after i type this code in it gives... (6 Replies)
Discussion started by: mbabeli
6 Replies
Login or Register to Ask a Question