csh

Changing a directory of the parent shell [duplicate]

余生颓废 提交于 2019-12-25 00:01:44
问题 This question already has answers here : Why doesn't “cd” work in a shell script? (29 answers) Closed last year . I 'm wondering of any mechanism that one could use to change the directory of a parent shell from sub-shell. For ex., I 'm running the script "settings.sh" in my $HOME. My $HOME has a directory $HOME/TEST/run. If my "settings.sh" scripts is as below #!/bin/bash # some shell related code # some shell related code cd $HOME/TEST/run exit 0 I execute the above script at command prompt

How to show line number when executing csh script?

谁都会走 提交于 2019-12-24 13:14:38
问题 I am using csh script and I want to see the line numbers when executing csh script in debug mode. I am doing like csh -x script_name What do I have to do apart from this to see line numbers in debug mode? 回答1: There is no built-in feature to do this. The only method I can think of is (ab)using the postcmd special alias. This alias will be run after every command: set _lineno = 0 alias postcmd '@ _lineno++ && echo -n $_lineno\ ' echo a echo b echo c && echo d Outputs: % csh test.csh 1 2 a 3 b

ampersand at beginning of a line in csh

十年热恋 提交于 2019-12-22 10:21:38
问题 What does an ampersand at the beginning of a line do in csh? It seems to be ignored (with no error message), but why? 回答1: Found something interesting: The semicolon (;) character separates successive commands on a single command line. For example, % <command1> ; <command2> executes <command1>, and when it finishes, <command2> gets executed. The ampersand character (&) is similar to the semicolon (;) but does not wait for <command1> to finish. Maybe it's treating it like an empty command? 回答2

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

 ̄綄美尐妖づ 提交于 2019-12-22 04:15:11
问题 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});

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

女生的网名这么多〃 提交于 2019-12-21 12:40:23
问题 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

How to color a prompt on FreeBSD/cshrc?

自作多情 提交于 2019-12-20 10:45:07
问题 I'm being put in charge of managing a bunch of servers, I want to set up my prompts on each of them so that I don't get confused as to where I am logged in to. I've edited my .cshrc files and put this in them: set prompt=`whoami`@`hostname -s`:$cwd'$ ' But I'd like to color that prompt so it stands out a bit more. Maybe green with white text or something. How can I do that? I'm not very familiar with the shell syntax. I'm SSH-ing in from the standard terminal that comes with Ubuntu, if that's

Problems creating Tables from command line Mysql

偶尔善良 提交于 2019-12-20 05:52:47
问题 When I type in the code into the Terminal it creates the Database but doesn't create the Table. When I type in use "locations" then "Show TABLES" it tells me that no Tables were created. This code should create a Database and the Table then import the the csv file into the database "locations" mysql -u root --password=password -e "CREATE DATABASE locations;" "CREATE TABLE location_T (number1 INT NOT NULL, number2 INT NOT NULL, number3 INT NOT NULL, names VARCHAR(100) NOT NULL,PRIMARY KEY

why is a double-quoted awk command substitution failing in csh

泪湿孤枕 提交于 2019-12-20 05:42:16
问题 Using C shell, the following command-line set pf = "`awk -v var=$pd '{if($1<0) print var, $2, $3}' test.txt`" returns an error in awk: awk: {if( <0) print var, , } syntax error. This is especially puzzling as the command itself works without any problem: awk -v var=$pd '{if($1<0) print var, $2, $3}' test.txt Is there a way that we can store all output of the single Awk command line into a single variable? What is the reason the above is failing? 回答1: After some tinkering, I can only come to

How to redirect stdout and stderr from csh script

十年热恋 提交于 2019-12-19 17:33:47
问题 For the following script install.csh: #!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1 Intended use: ./install.csh |& tee install.log How can I change the script so that I still get a install.log and the output on console without asking the user to do the redirecting? 回答1: Some simple solutions: Solution 1: tee every line you want to log independently, make use of -a switch of tee to append #!/bin/csh -f tar -zxf Python-3.1.1.tgz

How to redirect stdout and stderr from csh script

不问归期 提交于 2019-12-19 17:32:37
问题 For the following script install.csh: #!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1 Intended use: ./install.csh |& tee install.log How can I change the script so that I still get a install.log and the output on console without asking the user to do the redirecting? 回答1: Some simple solutions: Solution 1: tee every line you want to log independently, make use of -a switch of tee to append #!/bin/csh -f tar -zxf Python-3.1.1.tgz