Sponsored Content
Top Forums Shell Programming and Scripting C shell script passing arguments problem. Post 302989381 by bestard on Wednesday 11th of January 2017 10:39:39 PM
Old 01-11-2017
C shell script passing arguments problem.

I found something insteresting when I tested passing arguments into my scripts.
My scripts is as below.

Code:
% cat passarg.env 
#!/bin/csh 

echo "passarg: argv[1] = $argv[1] argv[2] = $argv[2]"
passarg1.env $*

Code:
% cat passarg1.env
#!/bin/csh

echo "passarg1: argv[1] = $argv[1] argvp[2]=$argv[2]"
set str = "test passing arguments"
source passarg2.env "$str"

Code:
% cat passarg2.env
#!/bin/csh

echo "passarg2: argv[1] = $argv[1]"

When I test my scripts on Solaris 8. The results showed as following.
Code:
% passarg.env abc cde
passarg: argv[1] = abc argv[2] = cde
passarg1: argv[1] = abc argvp[2]=cde
passarg2: argv[1] = abc

But when I tested it on RHEL 6.5 the results showed as below.
Code:
% passarg.env abc cde
passarg: argv[1] = abc argv[2] = cde
passarg1: argv[1] = abc argvp[2]=cde
passarg2: argv[1] = test passing arguments

Ideally, the Linux results should be correct.
Unfortunately, I don't know how to check Solaris built-in csh version
I only found tcsh package info as below.
Code:
% pkginfo -l SUNWtcsh
   PKGINST:  SUNWtcsh
      NAME:  Tenex C-shell (tcsh)
  CATEGORY:  system
      ARCH:  sparc
   VERSION:  11.8.0,REV=2000.01.08.18.12
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  Tenex C-shell (tcsh)
    PSTAMP:  on28-patch20040130230639
  INSTDATE:  Sep 19 2007 16:10
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:        7 installed pathnames
                   5 shared pathnames
                   5 directories
                   1 executables
                1034 blocks used (approx)

I kept wondering this should be a bug of Solaris 8 C-shell.
Does anybody have idea?
Except upgrading C-shell version, is there any workaround to solve this issue?

Thanks.

Last edited by rbatte1; 01-12-2017 at 07:38 AM.. Reason: Broke up the the scipts to seaparte block for clarity
 

10 More Discussions You Might Find Interesting

1. Solaris

Passing arguments to a shell script from file while scheduling in cron

Hi, I have a shell script Scp_1.sh for which I have to pass 2 arguments to run. I have another script Scp_2.sh which in turns calls script Scp_1.sh inside. How do I make Scp_1.sh script to read arguments automatically from a file, while running Scp_2.sh? -- Weblogic Support (4 Replies)
Discussion started by: weblogicsupport
4 Replies

2. Shell Programming and Scripting

passing runtime arguments to a shell script...

hi I am new to shell programming.....my question is while running one of my shell program it stops in between to accept input from the user and proceeds furthur after giving input....I want to know whether I can set this input through some files so that the shell acript reads the input from the... (10 Replies)
Discussion started by: santy
10 Replies

3. Shell Programming and Scripting

problem passing arguments to script

Hi, I am writing a script, which is invoked from other system using ssh. I have problems reading the arguments passing to the script. If the argument has a space in it (ex "rev 2.00"), the script considers "rev" as 1 argument and "2.00" as another. Instead i want "rev 2.00" to be considered... (5 Replies)
Discussion started by: cjjoy
5 Replies

4. Shell Programming and Scripting

Problem passing arguments to a Python script

I have part of the script below and I tried calling the script using ./tsimplex.py --fstmod=chris.cmod --nxz=8x6 --varp=0.25 but am getting the error option --fstmod must not have an argument Any idea on how to fix this would be highly appreciated #! /usr/bin/python import... (0 Replies)
Discussion started by: kristinu
0 Replies

5. Shell Programming and Scripting

Help required in passing multiple arguments from a shell script to a pl/sql block

Hi, hope everyone are fine. Please find my issue below, and I request your help in the same In a configuration file, i have a variable defined as below TEST = 'One','Two','Three' I am trying to pass this variable in to a sql script which is define in a pl/sql block as follows, In the... (1 Reply)
Discussion started by: ramakanth_burra
1 Replies

6. Shell Programming and Scripting

Passing arguments from a bash shell script to a command

I'm pretty new to bash scripting and I've found myself writing things like this (and the same with even more nesting): if $CATEGORIES; then if $LABEL_SLOTS; then $pyth "$wd/texify_grammar.py" "$input" "$texfile" "--label-slots" "--categories" "$CATEGORY_LIST" ... (9 Replies)
Discussion started by: burbly
9 Replies

7. Programming

Passing arguments from java to script shell

Hello Please i want to pass parameter (the string s) to the shell script: Quote: String s="Hello"; Process process = Runtime.getRuntime().exec("sh script1.sh"); How can i do please? Thank you (0 Replies)
Discussion started by: chercheur857
0 Replies

8. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

9. Shell Programming and Scripting

Passing multiple arguments to a shell script

Hi Gurus, Need some help with the shell scripting here. #!/bin/ksh ps -ef | grep -i sample.ksh | grep -v grep > abc.txt if then echo "sample.ksh is executing" else echo "sample.ksh is not executing" fi (1 Reply)
Discussion started by: jayadanabalan
1 Replies

10. UNIX for Beginners Questions & Answers

Passing Arguments to shell script from file is not working as expected.

Hi All, I have below simple shell script in cloudera quick start vm cenos 6 which copy file from source to destination. # file_copy.sh source_dir = ${source_dir} target = ${target_dir} cp source_dir target and my parameter file is like below #parameter_file.txt source_dir =... (4 Replies)
Discussion started by: Narasimhasss
4 Replies
All times are GMT -4. The time now is 09:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy