I have this shell script

#!/bin/csh
@ x = 1
while ($x <= 2)
nohup ./prog1 && ./prog2 &
@ x ++
end

I want to run sequentially for 2 times prog1 and prog2 that are previously compiled trough a makefile. How can I do it? Is the script right?

If I do

chmod u+x test.csh
./test.csh

I get this error

./prog1: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./prog1)

This is my makefile

GSLFLAGS := `pkg-config --cflags gsl`  
LIBGSL := `pkg-config --libs gsl`
CFLAGS = -O3 -fopenmp
LIBOMP = -lgomp

dist.o:dist.cxx
    g++ -Wall -c dist.cxx

prog1.o:prog1.cxx
    g++ -Wall -c prog1.cxx  $< ${GSLFLAGS} ${CFLAGS}

prog1:prog1.o dist.o 
    g++ ${CFLAGS} -o  $@ $^ ${LIBGSL} 

prog2.o:prog2.cxx
    g++ -Wall -c prog2.cxx  $< ${GSLFLAGS} ${CFLAGS}

prog2:prog2.o dist.o 
    g++ ${CFLAGS} -o  $@ $^ ${LIBGSL} 
有帮助吗?

解决方案

It appears that the search path for the standard C++ library is set differently in csh vs. when you run from the command line.

Linking the standard libraries statically should make the library search path irrelevant: change your makefile as follows:

CFLAGS = -O3 -fopenmp -static-libgcc -static-libstdc++

其他提示

If you really want to do what you ask, use this:

#!/bin/csh
./prog1
./prog2
./prog1
./prog2

I sense you are confused by backgrounding process and the like.

Run prog1 then prog2 if prog1 exits successfully:

./prog1 && ./prog2

Run prog1 and then prog2 regardless:

./prog1; ./prog2

Run prog1 in the background:

./prog1 &

Sleep 8 seconds then ring bell, but give me back my prompt immediately:

(sleep 3; sleep 5;echo $'\a') &
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top