I am sourcing a file under tcsh. This file could be anywhere on the filesystem. How can I retrieve the path of my sourced file ?
$0 won't work : I don't execute the file, I source it.
Many thanks !
I need help to translate the following bash code to tcsh :
case $TERM in
(xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}\007"'
;;
esac
It is part of my .bashrc on all the machines which have bash as login shell. The code sets the GNOME terminal title to user@somehost (obviously with the real user name and host name). However some hosts have tcsh as login shell, so I need to translate the code into tcsh and add it to the .tcshrc .
I considered to somehow source another file with the bash code from inside the .tcshrc file, but I couldn't make it work.
Having trouble executing an IF statement through tcsh.
This works FINE for me -
#!/bin/bash
if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"`
then
echo "present"
else
echo "absent"
fi
This is the PROBLEM -
#!/bin/tcsh
if echo `cal|tail -6|sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' |tr -s '[:blank:]' '\n' | head -11|tail -10|tr -s '\n' ' '`|grep -w `date "+%e"`
then
echo "present"
else
echo "absent"
endif
Getting this error-
if: Expression Syntax.
then: Command not found.
I really need this to run using "tcsh"
Today's Daily Vim says this:
Assuming you're using the bash shell, the following can be helpful when composing long command lines.
Start typing on the command line and then type Ctrl-x Ctrl-e, it should drop you into your system's default editor (hopefully Vim) and allow you to edit the command line from there. Once finished, save the command line, and bash will run the command.
Is there any way to do this in tcsh?
Someone in IT thought it would be a good idea to modify the default behavior of the command cd in our tcsh environment. As of Monday the "upgraded" version of cd always prints out $PWD after it navigates to the new directory.
e.g.
% cd ~/
Directory: /nfs/pdx/home/rbroger1
which cd yields no results so it isn't being alias'd.
Is there some environment variable or normal tcsh variable that is being set in our setup scripts to produce this output? I don't want to change all my scripts to use a wrappered or alias'd cd. I just want plain ol' cd.
I've got a tcsh shell script that I would like to stop with an error on nonzero status most of the time, but in some cases I want to ignore it. For example:
#!/bin/tcsh -vxef
cp file/that/might/not/exist . #Want to ignore this status
cp file/that/might/not/exist . ; echo "this doesn't work"
cp file/that/must/exist . #Want to stop if this status is nonzero
open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests"|);
while(<UNIT_TESTER>){
reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /core dumped/;
reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /\[ FAILED \]/;
writelog($tsttgt,$_);
}
close UNIT_TESTER;
I have tried to redirect stderr to stdout using this syntax but it didn't work:
open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests >& "|);
I have also read the discussion on the perl FAQ but that was in relation to bash: http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q5.15.html
Say I put an executable tcsh file in /path/to/my_script.csh
and my current directory is anywhere, for example I'm in /path
So I type to/my_script.csh
I want to have a line in my_script.csh that will return "/path/to/my_script.csh" - like ruby's
__FILE__
i am trying to set the environment variables in tcsh shell and it is not working. This is the syntax that i am using currently
setenv MYSQL_HOME=/opt/mysql/mysql/bin
my other question is i have a c-shell script that i am editing. Is setenv the same as a regular set MYSQL=${MYSQL_HOME}/bin/sqlplus?
set MYSQL_HOME=/opt/mysql/mysql/bin
or should i just set the MYSQL_HOME to where the mysql executable is ?
I'm trying to write a utility script that defines certain aliases.
My SHELL is tcsh (can't change that).
I tried the following
#!/bin/tcsh
alias log 'less ~/logs/log.date '+%Y%m%d'''
Then I run it like this:
./myscript
log
The output I get is: log: Command not found.
Naturally if I run it like this:
source myscript
log
Everything is fine.
Any way to do it without specifying source ...?
can somebody explain me what does this error mean:
> ./rank lines.in
'nknown option: `-
Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].
this is my script rank:
#! /bin/tcsh -f
set line = `cat ${1}`
echo $line
I think that the problem I have is with first row #! /bin/tcsh -f
I'm working on Windows! but after I wrote script on windows editor, I converted it using dos2unix rank, what can be the problem, thanks in advance for any help
somebody knows what does this error mean?
Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ].
I receive this error after I enter in my script this row
#! /bin/tcsh -f
This is a bit of a followup to this question. I have the following in my .cshrc:
alias res_t 'xtset -t %h:%d "(%u:%g)" %e' # reset titlebar
res_t # reset title right now
alias precmd res_t
And this works fine!
However, when I run screen I see that the title doesn't get updated with the current directory. How can I make screen update the xterm title?
Note: I am working in tcsh.
This is a bit of a followup to this question. I'm working in tcsh within GNU screen in an xterm.
I have the following in my .cshrc:
alias res_t 'xtset -t %h:%d "(%u:%g)" %e' # reset titlebar
res_t # reset title right now
alias precmd res_t
And this works fine!
However, when I run screen I see that the title doesn't get updated with the current directory. How can I make screen update the xterm title?
How do I get tcsh to stop asking if I want to list files in a directory that may have a lot of auto-completes?
For example, if I do: xemacs ../"TAB" to get the list of files it asks:
There are 371 rows, list them anyway? [n/y]
I don't want it to ask this, just list them.. it's getting tiresome.
(Or how to at least set the tolerance to a higher number of auto-completes before it asks)
Thanks.
Hi, I am using tcsh and define an environmental variable as follows:
setenv mycomp [email protected]
so that when I need to copy files from the remote my.computer.com, I type the following:
scp $mycomp:sourcepath destpath
But when I do this, I get the following error: "Bad : modifier in $ (m)." where (m) is the first character after the colon.
What is this error telling me, and how can I fix it?
I'm workin on C-Shell, can somebody help me find the bug, my script:
#! /bin/tcsh -f
cut -d" " -f2 ${1} | ./rankHelper
script rankHelper:
#! /bin/tcsh -f
set line = ($<)
while(${#line} != 0)
cat $line
set line = ($<)
end
file lines from which the data was sent:
053-3787837 038280083
052-3436363 012345678
053-3232287 038280083
054-3923898 033333333
052-2222333 012345678
052-1111111 012390387
I run it using:
> ./rank lines
why do I receive only one number
038280083
I thought cut must cut 2 field from all rows... thanks in advance for any help
I expect to see second field from all rows from lines
Hello all, I am having a problem with vim 7.2 hanging (for about 10 seconds) after it parses the .vimrc file. I had a similar issue in the past with tcsh on linux, but it was resolved by setting TERM to xterm-color. The same does not resolve the issue here. Any idea what may be causing this?
$ env
USER=redacted
LOGNAME=redacted
HOME=/home/redacted
PATH=redacted
MAIL=/var/spool/mail/redacted
SHELL=/bin/tcsh
TZ=redacted
LC_COLLATE=C
SSH_CLIENT=redacted
SSH_CONNECTION=redacted
SSH_TTY=/dev/pts/11
TERM=dtterm
HOSTTYPE=sun4
VENDOR=sun
OSTYPE=solaris
MACHTYPE=sparc
SHLVL=1
PWD=/home/redacted
GROUP=redacted
HOST=redacted
REMOTEHOST=redacted
QUOTA_CHECKED=1
WHOAMI=redacted
HOSTNAME=redacted
EDITOR=vim
PRINTER=redacted
INFOPATH=/software/gnu/gcc/2.8.1/sun4os5.10/info:/software/gnu/sun4os5/info:/software/gnu/emacs/20.3.1/sun4os5/info:/software/gnuish/sun4os5/info:/usr/local/gnu/info
MANPATH=/software/gnu/gcc/2.8.1/sun4os5.10/man:/software/gnu/sun4os5/man:/software/gnu/emacs/20.3.1/sun4os5/man:/opt/rational/clearcase/doc/man:/usr/openwin/man:/usr/share/man:/usr/local/man:/usr/dt/man:/software/gnuish/sun4os5/man
H_ARCH=sun4
H_ARCHOS=sun4os5
H_ARCHOS_SUB=sun4os5.10
H_OSTYPE=SUNOS
H_OSREV=51000
T_ARCH=sun4
T_ARCHOS=sun4os5
T_ARCHOS_SUB=sun4os5.10
T_OSTYPE=SUNOS
T_OSREV=51000
X11HOME=/usr/local/x11/sun4os5
OPENWINHOME=/usr/openwin
LD_LIBRARY_PATH=/usr/dt/lib:/usr/openwin/lib
MOTIFHOME=/usr/dt
XINITRC=/usr/openwin/lib/Xinitrc
GCC_REV=281
Hey,
I'm writing a shell script (tcsh) that is supposed to received 3 parameters or more. The first 3 are to be passed to a program, and the rest are supposed to be passed to another program. All in all the script should look something like:
./first_program $1 $2 $3
./second program [fourth or more]
The problem is that I don't know how to do the latter - pass all parameters that are after the third.
I have the following alias in my .aliases:
alias gi grep -i
and I want to look for foo case-insensitively in all the files that have the string bar in their name:
find -name \*bar\* | xargs gi foo
This is what I get:
xargs: gi: No such file or directory
Is there any way to use aliases in xargs, or do I have to use the full version:
find -name \*bar\* | xargs grep -i foo
Note: This is a simple example. Besides gi I have some pretty complicated aliases that I can't expand manually so easily.
Edit: I used tcsh, so please specify if an answer is shell-specific.
hello, can somebody recommend me good Linux text editor for Windows (if it exists), I wrote scripts for C-Shell using txt editor of windows but I have problem, it doesn't run cause windows is not UNIX, what can I do? I don't want to install linux for a few scripts, I do testing of my scripts via unix server (this server is not mine), thanks in advance
i am a real beginner in csh/tcsh scripting and that's why i need your help. The problem is I have to go through some regular files in directories and find those files, that have their own name in its content. In the following piece of script is cycle in which I am going through paths and using grep to find the file's name in its content.
What is surely correct is $something:q - is array of paths where i have to find files.
The next variable is name in which is only name of current file.
for example: /home/computer/text.txt (paths)
and: text.txt (name)
And my biggest problem is to find names of files in their content. It's quite difficult for me to write correct grep for this, cause the names of files and directories that i am passing through are mad. Here are some of them:
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/!_1
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/dam/$user/:e/'/-r
/home/OS/pocitacove/testovaci_adresar/z/test3/skusime/ taketo/ taketo
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/.-bla/.-bla/.a=b
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/.-bla/.-bla/@
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/.-bla/.-bla/:
/home/OS/pocitacove/testovaci_adresar/z/test4.pre_expertov/.-bla/.-bla/'ano'
foreach paths ($something:q)
set name = "$paths:t"
@ number = (`grep -Ec "$name" "$paths"`)
if ($number != 0) then
echo -n "$paths "
echo $number
endif
@ number = 0
end
I have a pov-ray file, which defines a lot of cylinders and spheres. Sometimes these shapes are defined to have "color@", which makes the povray unrenderable. One solution I've found is to delete the offending cylinders and spheres. So a file that contains this text
cylinder {
< -0.17623, 0.24511, -0.27947>, < -0.15220, 0.22658, -0.26472>, 0.00716
texture { colorO }
}
sphere {
< -0.00950, 0.00357, 0.00227>, 0.00716
texture { color@ }
}
cylinder {
< -0.00950, 0.00357, 0.00227>, < 0.00327, 0.00169, 0.00108>, 0.00716
texture { color@ }
}
sphere {
< 0.15373, 0.00601, 0.18223>, 0.00716
texture { colorO }
}
would turn into this text
cylinder {
< -0.17623, 0.24511, -0.27947>, < -0.15220, 0.22658, -0.26472>, 0.00716
texture { colorO }
}
sphere {
< 0.15373, 0.00601, 0.18223>, 0.00716
texture { colorO }
}
Is there some way to do this replacement with a shell script? Preferably in tcsh. Thanks!
This is related to http://superuser.com/questions/27376/why-does-my-ld-library-path-get-unset-launching-terminal, but a different set of symptoms.
First, /usr/bin/screen is setuid as per the other question. Second, the default shell on this system is /bin/tcsh for various historical reasons, and we're not allowed to chsh to /bin/bash, so I typically run bash manually immediately after login. Third, I almost always use screen, but I want ctrl-a ctrl-c in screen to create a new bash "tab", so I always invoke bash first.
That is:
{~} $ echo $SHELL
/bin/tcsh
{~} $ bash
[~] echo $SHELL
/bin/bash
[~] screen -U
[~]
...and when reconnecting:
{~} $ echo $SHELL
/bin/tcsh
{~} $ screen -dUr
[~] echo $SHELL
/bin/bash
[~]
However, my $LD_LIBRARY_PATH is there in tcsh, there in bash, but empty once I run screen; it is still present if I just run screen from tcsh, but then I get new tcsh "tabs" when I use ctrl-a ctrl-c in screen.
Any ideas?