Argv not found (script shell)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Argv not found (script shell)
# 1  
Old 08-19-2014
Argv not found (script shell)

I don't know whether it is possible that I ask for help concerning a shel sscript that i wrote and which is not working.
So here is my shell script:
Code:
#! /bin/bash

if($#argv != 1) then
    echo "hoge"
    exit
endif

set tgtdir = ../../result
set target = ${tgtdir}/s${argv[1]}/1
set datafile = "agent.csv track.csv knock.csv check.csv"
set paramfile = "agentdata.csv statemap.csv"

echo "experiment 1 start..."
./main 1
echo move to ${target}
if(!(-d ${target})) then
  mkdir -p ${target}
endif

mv ${datafile} ${target}
cp ${paramfile} ${target}

So i attribute the rights for the execution using the chmod +x and then i execute while i m in the directory where the script sheel is located:
./exp.sh 14 but still no directory is created in the directory result and also i got the error argv:command not found ! I cannot find the reason . it might be so clear but i m mind blinded ! Please help me and thanks for your assistance.

Last edited by Franklin52; 08-19-2014 at 03:26 AM.. Reason: Please use code tags
# 2  
Old 08-19-2014
It says bash in the shebang, but the syntax looks like csh to me..
# 3  
Old 08-19-2014
Ok so I changed the script as follows :

Code:
#! /bin/bash

if($#argv != 1) then
    echo "hoge"
    exit
fi

set tgtdir = ../../result
set target = ${tgtdir}/s${argv[1]}/1
set datafile = "agent.csv track.csv knock.csv check.csv"
set paramfile = "agentdata.csv statemap.csv"

echo "experiment 1 start..."
./main 1
echo move to ${target}
if(!(-d ${target})) then
  mkdir -p ${target}
fi

mv ${datafile} ${target}
cp ${paramfile} ${target}

But still not working! Please help me

Last edited by Scrutinizer; 08-19-2014 at 04:19 AM.. Reason: code tags
# 4  
Old 08-19-2014
You are using the wrong shell. Try using csh instead of bash
# 5  
Old 08-19-2014
I put csh instead of bash and i restore the ancient script but whenever, I try to execute, it did not work at all !
# 6  
Old 08-19-2014
How did you use csh instead of bash ? Did you change the shebang? Show us what you did. I noticed that you changed endif to fi twice, but that is the wrong syntax in csh. If you want to rewrite the script to bash you need to make more changes...
# 7  
Old 08-19-2014
Thanks for your answer. I rewrite the script using the bash syntax while Ihope it is correct but still not working !
Code:
#! /bin/bash

if($#argv != 1); then
    echo "hoge"
    exit
fi

set tgtdir = "../../result"
set target = "${tgtdir}/s${argv[1]}/1"
set datafile = "agent.csv track.csv knock.csv check.csv"
set paramfile = "agentdata.csv statemap.csv"

echo "experiment 1 start..."
./main 1
echo move to ${target}
if(!(-d ${target})); then
  mkdir -p ${target}
fi

mv ${datafile} ${target}
cp ${paramfile} ${target}


Last edited by Franklin52; 08-19-2014 at 05:22 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX shell script error: not found

Hello All, I'm working on one Unix shell sript that will actually extract a column data from Oracle table using sqlplus and writes onto a file. I'm getting this error when executing the shell script: rpt.ksh: ^JScott: not found Below is the code in the shell script: `sqlplus -s... (1 Reply)
Discussion started by: venkat_reddy
1 Replies

2. Shell Programming and Scripting

+: not found Error in shell script

Hi , I am a newbie to shell scripting. I am getting the error on AIX machine /tadfdc_setup_fed.sh: +: not found Here tadfdc_setup_fed.sh is script which works fine on Linux Machine. But gives error on AIX (1 Reply)
Discussion started by: Anupam Kakade
1 Replies

3. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

4. UNIX for Dummies Questions & Answers

Launch shell script if string match is found

I'm trying to write a simple shell script that looks at a given text file and if the only word in the file is 'completed', it launches another shell script. So far I have this almost working... if grep 'completed' $datafile then... however, using this logic the secondary shell script... (3 Replies)
Discussion started by: MickeyGreen
3 Replies

5. Shell Programming and Scripting

argv usage in a korn shell script

I'm trying to count and display the variables on a command line #!/bin/ksh $# argv from command line: tryit2 this is a test returns : tryit2: 4: not found. (1 Reply)
Discussion started by: Bperl1967
1 Replies

6. Programming

C shell deciphers someones code & argv

I’m trying to work off of someone else code they gave me as an example but they are gone! I’m trying to pretty much write a wrapper of several different scripts. They use argv…I keep on thinking the next one should be argv ect. I’m not sure if maybe its different in PERL maybe if that’s true? Or... (5 Replies)
Discussion started by: carbuncle11
5 Replies

7. Shell Programming and Scripting

Command not found in shell script - stumped for 4 days

Hello, I like to begin with :wall:.. literally... It has been 4 days and I have no idea how to fix it. Environment - AIX 5.3 I wrote a script to call on ssh to log into another box via PKA to do something else. If I run the script on the terminal, it works 100%. If the SAP customised... (11 Replies)
Discussion started by: plonkagain
11 Replies

8. Shell Programming and Scripting

rm:command not found in linux Bash shell script

Hi All, Linux lxs3er06 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux Issue: While executing shell scripts in bash shell, following error messages are thrown: rm:command not found On doing little investigation, I added '/bin' to $PATH and on doing echo... (9 Replies)
Discussion started by: a1_win
9 Replies

9. Shell Programming and Scripting

found error 138 while run shell script

I found error 138 while run a shell script. Please tell me what it's mean?? and how can i prevent that error. Thanks in advance..... (1 Reply)
Discussion started by: rinku
1 Replies

10. Shell Programming and Scripting

Shell script run error ksh: not found

Hi All, I am trying to run a script to FTP files from one UNIX server to another UNIX server. Actually I can able to FTP file successfully by manually or paste whole script at prompt. But when I am trying to run script it is giving error. Please let me know the cause. #!/bin/sh... (3 Replies)
Discussion started by: nz80qy
3 Replies
Login or Register to Ask a Question