Running same unix script in different shells

unix

    Next

  • 1. Flex/Bison Question (lex & yacc example question)
    Hi all, I've just been having this bison/flex question and well, though this would be a good place to ask. Just reading lex & yacc book and trying example ch3-01. I have calc.l: %{ #include "calc.tab.h" extern int yylval; %} %% [0-9]+ { yylval = atoi{yytext}; return NUMBER; } [ \t] ; \n return 0; . return yytext[0]; %% and calc.y: %token NAME NUMBER %% statement: NAME '=' expression | expression { printf("= %d\n", $1); } ; expression: NUMBER '+' NUMBER {$$ = $1 + $3; } | NUMBER '-' NUMBER {$$ = $1 - $3; } | NUMBER {$$ = $1; } ; When I try to compile... no matter gcc version (tried 2.95 and 3.3.5) I get: pmatos@euler calc $ gcc lex.yy.c calc.tab.c -o calc calc.l: In function `yylex': calc.l:8: warning: assignment makes integer from pointer without a cast calc.l:8: parse error before `{' calc.l:10: case label not within a switch statement calc.l:11: case label not within a switch statement calc.l:12: case label not within a switch statement calc.l:13: case label not within a switch statement lex.yy.c:630: case label not within a switch statement lex.yy.c:633: case label not within a switch statement lex.yy.c:755: default label not within a switch statement lex.yy.c: At top level: lex.yy.c:760: parse error before `}' In the book everything seems to work fine. Any suggestions? (using bison 2.0 and flex 2.5.4a) Cheers, Paulo Matos
  • 2. viewing binaries as 1s and 0s
    hi, Is there a command that when run on a binary file shows 0s and 1s instead of gibberish ? cheers, chax.
  • 3. Socket errors and errno.
    Hi, I am fairly new to socket programming and am extremely paranoid about making sure I catch any error condition that may affect my application (and attempt a recovery if possible). I am using the select() function to notify my program of socket events. My application sends data to remote host. I have used shutdown() to disbable socket reads so that client applications cannot send me data. If I lose connection (for whatever reason) with any remote hosts or my write socket fails (for wahatever reason) I need to take remdial action (if possible) re-establish the connection (if possible) and continue to send data. I wonder if anyone could point me in the direction of any resources which may help with the following queries: 1> If a remote host disconnects the select function will inform me that the socket is ready to read/write. I am intending to use the value of errno if my write attepmt (which will fail if disconnected) to the socket to diagnose the problem and trigger my application to re-establish the connection with the remote host. Does this seem a sensible approach? 2> What error conditions should I check for to determine errors on my local (write) socket. If I detect errors with my local socket is it best to drop the socket and create a new socket before attempting to reconnect to the remote host? Many thanks Lawrie
  • 4. Timezone change questions
    On Linux, do gmtime and localtime with the TZ set correctly take into account changes in daylight savings time definitions over the years? And, does the TZ set change the current TZ for all threads or just the current thread? If so, is there a way to pass a timezone to the gmtime and localtime functions to get a correct and threadsafe time zone? Thanks!
  • 5. looking for AIX cmd
    i'm looking for a AIX5.1 command which will print out all system resources ie disks, cpu (speed), memory (physcal / virtual), IP, model #, serial # pretty much everything you need for a systen aduit. thanks

Running same unix script in different shells

Postby c_jena » Sat, 09 Apr 2005 18:02:12 GMT

How can I port same shell script in to different shells like C Shell, K
Shell and Bourne Shell

Chitta


Re: Running same unix script in different shells

Postby Pascal Bourguignon » Sat, 09 Apr 2005 21:41:04 GMT

 XXXX@XXXXX.COM  writes:


Launching your favorite editor, reading the man page of the source and
the target shell, thinking, and editing the script file.

Also, it's possible to write a single source file usable both in csh,
sh, Fortran and C, and perhaps it would be possible to add  more
languages, so  you would not need to "port" the script...


happy.source:
------------------------------------------------------------------------
cat /*dev/null; echo "Happy New Year"\!
cat <<c*/ /*dev/null | cat > /dev/null
c */ () {} /*
c */ main() { cat(); printf("Happy New Year!\n"); } /*
17      format('Happy New Year!')
        write (6,17)
        stop
        end
c*/
------------------------------------------------------------------------


Makefile:
------------------------------------------------------------------------
all: happy-c happy-f happy-sh happy-csh

happy-c:happy.source Makefile
	@ cp happy.source happy-c.c
	@ gcc -o happy-c happy-c.c
	@ echo -n '(C)            '
	@ ./happy-c || true

happy-f:happy.source Makefile
	@ cp happy.source happy-f.f
	@ f77 -o happy-f  happy-f.f 2> /dev/null
	@ echo -n '(FORTRAN)      '
	@ ./happy-f

happy-sh:happy.source Makefile
	@ cp happy.source happy-sh
	@ echo -n '(Bourne Shell) '
	@ chmod 755 happy-sh
	@ sh ./happy-sh

happy-csh:happy.source Makefile
	@ cp happy.source happy-csh
	@ chmod 755 happy-csh
	@ echo -n '(C Shell)      '
	@ csh ./happy-csh

clean:
	-rm -f *.o *~ happy-csh happy-sh happy-f happy-f.f happy-c happy-c.c
------------------------------------------------------------------------

-- 
__Pascal Bourguignon__                      http://www.**--****.com/ 

In a World without Walls and Fences, 
who needs Windows and Gates?

Re: Running same unix script in different shells

Postby Ralf Fassel » Sat, 09 Apr 2005 23:18:20 GMT

* Pascal Bourguignon < XXXX@XXXXX.COM >
| happy.source:

kEWl, D00dE.

R'

Re: Running same unix script in different shells

Postby Heiner Steven » Wed, 20 Apr 2005 03:53:34 GMT




Since the KornShell was designed to be a compatible replacement
of the Bourne Shell, it's easy to write a script that runs
with both shells. Just limit yourself to the Bourne Shell
constructs, which are understood by both shells.

The C-Shell is something completely different, inventing
a completely independent command language. The Bourne Shell
and C-Shell command sets are disjoint by a large degree.

The following script shows, that it still is possible to
use all together in one script:

      http://www.**--****.com/ 

Heiner
-- 
  ___ _
/ __| |_ _____ _____ _ _     Heiner STEVEN < XXXX@XXXXX.COM >
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|    http://www.**--****.com/ 

Similar Threads:

1.Run Unix/Linux shell script from VB.NET

I believe I got this under VB6 but not sure if we can runUnix shell script 
from a VB.NET application

Your help is greatly appreciated.

Bill

2.Run Unix shell script from VB.NET

I have the need to run couple Unix shell scripts (in IBM AIX box) from a 
VB.NET windows app.
Please help!

Thanks a million.

Bill 

3.Running unix shell script from remote java app

Hi everyone,

My problem is, A have created a simple tool to run a shell scipt
located on a remote unix server via a ssh2 session (using ganymed-ssh2
library).

The output from this script when run from my java tool differs to the
output when the shell script is run directly on the server, some of the
output is not displayed, it seems so far that output generated in
functions contained in the shell script, or generated in loops in the
shell script are not displayed when run from my java tool.

As an attempted work around I created a wrapper sell script which was
suppossed to redirect the out put from the script into a tmp file, and
the java task read directly from that file- The strange thing is that,
I get the same problem, when I run the wrapper from unix, correct
output in tmp file is generated, when I run the warpper from my java
tool, not all output is generated in tmp file.

This seems like really strange behaviour to me, as anyone experienced
something like this before?

Basically the reason for the tool , is that we can not allow certain
junior employees to log onto client machines, however we need them to
be able to run certain scripts already located on the server. -


Any help or ideas would be greatly appreciated.

4.Running a Unix Shell Script from VBscript

Is there a way from WSH/VBscript to 

a) Remotely run a unix shell script on a unix server?

b)  Pass arguments to the script

c) Detect the unix scripts exit status.

Any help/pointers appreciated

-- 
JL

5.Coding an SFTP step in a Unix Script running F-Secure Shell

Hello,

I am not able to get a script to run using SFTP that will work.   I
looked and looked and cannot find any specific code to do this.   I am
running on AIX 5.1 and have successfully executed the ssh-keygen
command that created keys on both the source and target servers.   
Still failing.   Any help would be GREATLY appreciated.

Thanks,

6. Run Script From Comp.Unix.Shell FAQ - Not Interpreting Commands

7. how to run your tcsh shell script in the new shell

8. how to easily determine shell script is running in background from within script



Return to unix

 

Who is online

Users browsing this forum: No registered users and 38 guest