I dont know... When I write a script that runs on different OS which may not have the same version of software, path syntax etc... I test the OS and accordingly set the environment for my programs with the needed params... and it always works...
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
There have been discussions about static checkers for shell scripts. However, because of the flexibility of shell, there are times when the script really needs to be executed. For example:
Unless one processes the assignment, there is no way to tell if the command $ls will work, or even if it exists.
However, as an experiment and proof-of-concept, I wrote a perl script that, with many kludges, can process a number of the Bourne-shell-family statements to isolate commands that are not available. The perl is about 150 lines long.
An example shell script for input might be:
and running the perl code across it yields:
For the adventurous, there is a far-more-complete, complex, shell parser found at: Shell::Parser - search.cpan.org
This is not a complete scanner of scripts. For example, note that single-line if/while are not processed, but some shifting around of the perl would allow that. Constructs like until, select, etc. are not processed; case within case is not recognized.
The basic idea is to use 2 passes. In pass 1 the code is broken apart to allow ease of recognition in pass 2 by writing to a scratch file, then in pass 2 the scratch file is processed, resulting in the warnings, and notes.
I have a long script that adapts itself to different platforms. This perl code correctly identified the sw_vers OSX command as not being found on Linux, as well as SuSE command zypper not being found on Debian.
I have a shell script which is used to get the input and have another shell script (a sub script) at the end of this shell script which is used to upload the inputs in the Oracle database. I can check the execution status of the parent script using sh -x script.sh. but this command doesn't show the... (1 Reply)
I been having a lot of trouble trying to start up a 3rd party application in Solaris 7 but it seams that its missing entry's when trying to run the files so maybe the start shells scripts have errors and maybe thatr is what is causing the issues I have added two links to the shells can anyone check... (5 Replies)
Hi,
I am new to unix scripting and am jus getting to learn about it..
I need to know on how to check for the existence of a number of files in a path..i.e the files are ftp'ed from several other servers, should check if all the files have arrived, if not wait till they arrive..can i use a flag... (5 Replies)
HI All,
I am running one shell script, in that script i am calling 4 scripts in the background.
abc.ksh &
efg.ksh &
xky.ksh &
mno.ksh &
please let me know, how could i find the success and failure of each script.
i Cannot use $?, because i want to run all the scripts in parellel.
... (2 Replies)
Hi,
In the rpm SPEC file there is %pre section for preinstall scripts.
We can write any think in the "sh" format here.
I want to call a script here. How can i do this?
Thanks (2 Replies)
Question for anyone that might be able to help:
My objective is to eheck if a file (a source file) exists in a directory. If it does then, I'd like to call an application (Informatica ETL file...not necessary to know) to run a program which extracts data and loads it into multiple targets.
... (6 Replies)
Hi,
i have a script 'a.sh' that should be called only by certain scripts like b.sh, c.sh
Inside a.sh, how can i determine
1) if this script was run directly from command prompt (or scheduler)
2) if called via other scripts?
Is there an easy way to get parent process name (not just pid),... (2 Replies)
Hello:
Can someone please help me figure out what is wrong here, my script does not move on to the "else" part even though there is no .ssh directory on my remote server:
$more putkey.sh
#!/bin/ksh
for server in `cat list`
do
if ; then
cat $HOME/.ssh/id_rsa.pub |ssh $server ' cat >>... (4 Replies)
I have a Unix box abcd, where I have script1, script2 and script3 running. I have to write a 4th script script4 which would check my box(abcd) and kill all running scripts. How can I do that? (3 Replies)