Find the answer to your Linux question:
Results 1 to 5 of 5
Dear all, I'm writing a little bash script that, among other things, calls a csh script with 'source': source /path/scritp.csh but when I execute my script it will fail: ./montar_todo.sh: ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3

    Call 'source' from bash script. Please help...

    Dear all,

    I'm writing a little bash script that, among other things, calls a csh script with 'source':

    source /path/scritp.csh


    but when I execute my script it will fail:

    ./montar_todo.sh: /path/script.csh : line 15: syntax error near unexpected token `$#argv'
    ./montar_todo.sh: /path/script.csh : line 15: `switch ($#argv)'

    Is there anyway to safe call the csh script with 'source' ?

    Thank you

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    You do realize that you are asking the interpreter of one programming language to execute code written in another programming language, don't you? Why do you need to use source anyway?

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3
    The script is written in bash, but I need to call another script from there written in csh, with source, after asking the user some things. So this line must be present, executed with source as given by our software supplier:

    source /path/script.csh

    That csh script that I want to call from my script starts with:

    #!/bin/csh

    So I thought it won't have problems. But it does.

    Any help please...?
    Thank you

  4. #4
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    You either did not read or did not understand my comment. I will assume that I did not express myself clearly enough.

    In general, you can not source a shell script written for one shell in another shell because they do not use the same syntax. And this is, in fact, exactly what bash is complaining about.

    The source command reads a script and tries to execute it in the same shell instead of forking a new process. And that is, of course, the reason why I asked why you need to use source. You did not answer that question, however.

    Either you really have to use source for some obscure reason, then you will have to write your script in csh, too. Or you do not need to use source and can simply execute the csh script like any other program.

    I hope this is detailed enough.

  5. #5
    Just Joined!
    Join Date
    Nov 2008
    Posts
    3
    Ok!

    Now I understand. I'd better translate my script to csh.

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...