I need to run them on Flavors of Unix and Linux OS.
The problem occurs that a set of commands in the script fail on one Operating System or the other.
Below are a list of few commands that did not work on all operating systems i tested specifically becoz they are either located at different paths as they are not set in the user profile that i login with or those commands do not even exist on the System i run the script.
I wish to test my shell scripts on any Operating System and figure out what command or arguments to the commands are failing.
This can be done basically by grepping for "command not found" or " invalid arguments" strings in the output of the shell script run.
This is my requirement. Can you tell me if it actually able to find all the failing commands for "command not found" or " invalid arguments without executing the script.
Something like a dummy runs that executes the script only for me to collect the output without actually executing the commands on the OS.
Sort of a pseudo run rather than actual run of the scripts.
Let me know if & how is it possible.
Will be a great help. Thank you.
Last edited by mohtashims; 10-12-2016 at 12:18 PM..
If you can't even find find, you've got a horrible login profile, or are running from cron.
I m not dealing with crontab.
find command works and i can find find but the argument passed with find may not work on some systems. So i have to give the path to the feasible find among the many find command installed on that system.
By the way, like i asked in the OP is there a way to pseudo run my script rather than actual run ? or any trick up your sleeve ?
Last edited by mohtashims; 10-12-2016 at 02:03 PM..
Your explanation of find makes that especially difficult: find just existing isn't good enough, you actually need to know that it's a specific version. That's not the sort of thing you can discover without running it to see if it works.
I don't know what to suggest besides thorough error-checking. You could have variables like
AWK="mawk" and run them like $AWK -F: '{ code }' ... to make it easier to adapt your script to different systems.
You could also rewrite certain things more portably to avoid needing system-specific commands, i.e. using plain awk instead of GNU awk, etc.
You can create symlinks in a directory in the path pointing to the right command version.
You need to restrict your script to the minimal subset of commands/options common to ALL systems it runs on.
Most systems offer a way to set a basic (and basically working, if the system is set up sensibly) environment: in AIX (and other UNIXes) this is /etc/environment, in Linux this is /etc/profile, etc..
I have built on that and created a standard environment file for all of my scripts which gives me a constant environment by being sourced in in all my scripts. It is called f_env and looks like this (excerpt):
Most of my scripts start this way:
Notice that the variable DEVELOP is examined both in the script and the environment-file. The reason is i have this standard-environment together with a lot of shell-functions packaged into a "library" and always on the same place on every system (/usr/local/lib/ksh). Still i want to be able to test with newly written (or changed) library functions without messing with the public part. For this i have a variable "DEVELOP" set in my profile on my development system. When this variable is set FPATH is set to ~/lib and all the external shell functions are loaded from there instead.
This way i can test with my private copy of the library until i am ready to release the next version.
I hope this helps.
bakunin
These 2 Users Gave Thanks to bakunin For This Post:
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)