csh

How can I run a csh script from a tcl script?

三世轮回 提交于 2019-12-05 15:40:18
I am trying to run a csh script from a tcl script. The tcl script below calls a csh script #!/usr/bin/tclsh set scripts_path /scratch/TCL_scripts/scripts_adders set synthesis /scratch/TCL_scripts/synthesis.csh set files [glob -directory $scripts_path *] split $files set files [lsort $files] set i 1 foreach script $files { puts "hello" # puts [pwd] exec /bin/csh -c $synthesis puts $i } And the (begining of the) csh file is below: #!/bin/csh -f echo abcdefgh When I only execute the csh file from my unix terminal, it works fine. When I call my Tcl script, it runs and indeed writes "hello" and

How to run a tcsh shell command and selectively ignore the status?

别等时光非礼了梦想. 提交于 2019-12-05 10:13:16
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 I don't know about tcsh, but with bash, you can use set -e to do this. When the -e flag is set, bash will exit immediately if any subcommand fails (see the manual for technical details). When not set, it will continue to execute. So, you can

Invoking shell from java, it complaints “stty: standard input: Invalid argument”

偶尔善良 提交于 2019-12-05 06:36:57
I invoke a shell command by Process class from java and it prints "stty: standard input: Invalid argument" no matter whether the command is right or wrong (normal output of shell command is shown too). If I run the shell command in shell, no such error message is shown. The command is something like this: {"/bin/csh", "-c", "echo hello"} Try using the -f option of csh to disable the reading of the .chsrc and .login files: {"/bin/csh", "-cf", "echo hello"} You are invoking the stty command from your .profile , or .bash_profile . You'll have to redirect its standard error to /dev/null . stty

java.io.IOException: Cannot run program error=2, No such file or directory

拥有回忆 提交于 2019-12-05 02:21:22
I have a java class in which I call a runshellscript method that will execute a script. It worked well with mysql but I cannot seem to find out why it wont work well with psql. Here is an excerpt of my runshell method: public class RunShellScript { public static void runShellScript (String unixCommand) { try { Runtime runtime=Runtime.getRuntime(); //Process process=runtime.exec(new String [] { "/bin/csh", "-c", unixCommand}); Process process=runtime.exec(new String [] {unixCommand}); InputStream stderr=process.getErrorStream(); InputStreamReader isr=new InputStreamReader (stderr);

Redirecting stderr in csh

北战南征 提交于 2019-12-05 02:13:07
I'm executing a program that dumps crash report into STDERR from where I have to filter some necessary information. The problem is that I'm unable to redirect STDERR to STDOUT and PIPE it with grep command 2>&1 >/dev/null | grep "^[^-]" >& /tmp/fl Getting error: Ambiguous output redirect. Same command works under bash terminal. What should I change to make it work ? csh is significantly more limited than bash when it comes to file redirection. In csh , you can redirect stdout with the usual > operator, you can redirect both stdout and stderr with the >& operator, you can pipe stdout and stderr

In python 2.4, how can I execute external commands with csh instead of bash?

删除回忆录丶 提交于 2019-12-05 01:39:22
问题 Without using the new 2.6 subprocess module, how can I get either os.popen or os.system to execute my commands using the tcsh instead of bash? I need to source some scripts which are written in tcsh before executing some other commands and I need to do this within python2.4. EDIT Thanks for answers using 'tcsh -c', but I'd like to avoid this because I have to do escape madness. The string will be interpreted by bash and then interpreted by tcsh. I'll have to do something like: os.system("tcsh

alias in cshell with grave accents, apostrophes and more

独自空忆成欢 提交于 2019-12-04 15:55:42
I came across a weird behavior in the c-shell: when writing the following line, i get exactly the behavior I expect: ls -l | grep $USER | somescript `awk -F' ' '{print $1}'` meaning - it will search all items owned by me and activate 'somescript' with their first field as argument. however, when I try aliasing the same line, it jams my shell (or hands out error massages if i separate the braces from the apostrophe: alias doit 'ls -l | grep $USER | somescript `awk -F' ' '{print $1}'`' will result in either {: Command not found print: Command not found or simply not being able to start a new

Why doesn't rm work as I expect here?

血红的双手。 提交于 2019-12-04 14:03:41
I just want to do a simple thing. I got the following files in a directory: AppInterface.h baa PEMsg.h PluginInterface.h Then I issue the command: ls | grep -v ".h" | rm -rf Much to my dismay, baa does not get deleted. But, this: ls | grep -v ".h" gives baa as I expect. So I guess the problem is with how rm takes input but I don't know why. Tried this both in csh and bash. rm doesn't take input from stdin so you can't pipe the list of files to it. You need rm `ls | grep -v ".h"` or ls | grep -v ".h" | xargs rm -rf You want to use xargs : ls | grep -v ".h" | xargs rm -rf rm doesn't read a list

Display only files and folders that are symbolic links in tcsh or bash

会有一股神秘感。 提交于 2019-12-04 07:48:42
问题 Basically I want do the following: ls -l[+someflags] (or by some other means) that will only display files that are symbolic links so the output would look -rw-r--r-- 1 username grp size date-time filename -> somedir -rw-r--r-- 1 username grp size date-time filename2 -> somsdfsdf etc. For example, to show only directories I have an alias: alias lsd 'ls -l | grep ^d' I wonder how to display only hidden files or only hidden directories? I have the following solution, however it doesn't display

How to check if an environment variable is either unset or set to the empty string?

空扰寡人 提交于 2019-12-04 05:48:16
I don't want to use tcsh, but unfortunately have no choice in this situation. So please no "use another shell" answers! I'm currently trying to check that an environment variable is both set, and that it's set to something useful. So what I want to do is this: if ($?HAPPYVAR && $HAPPYVAR != "") then ... blah... else if ($?SADVAR && $SADVAR != "") then ... more blah ... endif The problem is that if $HAPPYVAR is unset, it will error out on the second half of the expression (because the environment variable replacement happens early). I could use nested ifs, but then I'd have problems getting my