Difficulty with a couple commands porting from korn shell to bash
I am relatively new to shell scripting. I have a script I wrote that works fine in korn shell.
I need to make it work in bash on a different server.
There are a couple valid korn shell commands I am having difficulty finding the bash equivalents for.
At one point the scripts prompts the user for their IP to export display. The read command used in the kornshell version to control a timeout is not valid in bash:
The error generated is read: -t: unknown option.
Users are asked later to specify the binary they want to run. bash is not interpreting the kornshell command. They are giving a list of binaries then script goes to the directory the binaries are in, and, if it is a valid name, executes it. If it is not found it just returns and invalid message.
None of the binaries are being found even though they are valid. The if [ -f ....] construct is not working in bash.
Any suggestions would be greatly appreciated. Thank you for your time.
On the original computer, what Operating System and version?
On the new computer, what Operating System and version?
Item 1) Standard "ksh" (ksh88) does not have "read -t". What ksh do you have?
Item 2) Please post sample values of $variable and matching error messages.
Ps: For X-Windows DISPLAY Environment Variable you should be able to detect your own IP address indirectly via an appropriate who am i command (syntax varies).
e.g. who -R am i or whatever is valid on your system and processed to extract the IP address.
Obviously this would remove the need for "read -t".
Last edited by methyl; 03-01-2012 at 08:38 PM..
Reason: corrections and addenda
Thank you for the suggestion methyl. I eliminated the read -t statement entirely.
Here is the exact error I am seeing with the is statement. I am trying to say if the variable is one thing, execute the listed commands. For anything else, check the relevant directory and if the bin file is there run it, if not throw an error. There is an issue with my elif statement.
The shell it worked on was ksh-20100202-1.el5_6.5 on Red Hat Enterprise Linux Server release 5.6 (Tikanga).
It it not working on version 3.2.25(1)-release (x86_64-redhat-linux-gnu) on Red Hat Enterprise Linux Server release 5.7 (Tikanga)
Thanks for replying. The executable is in a root owned directory. I do not get root access. Sudo rights were applied so the commands in the script execute as root. If I ls -l I will just get permission denied. I did confirm with a unix admin that the file exists.
OK, then what does sudo ls -l /test/apps/mstr/bin/mstrconnectwiz say? Or if the sudo rights are for the script itself, insert ls -l /test/apps/mstr/bin/mstrconnectwiz into the script to test its presence and or its readability of the directory it is in.
Last edited by Scrutinizer; 03-01-2012 at 10:28 PM..
I use plink.exe to automate remote commands that return data to Windows machines. This works well on newer servers running Red Hat since the commands were developed for bash and the designated user's login shell is bash. I need to also support older servers which are running Solaris 10 but the... (5 Replies)
Migrating Unix batch jobs (Korn Shell) running in HP-UX server to Linux environment.
Hi All
Please help me to understand the easiest way to migrate Kernel Shell scripts to Linux Bash. Also let me know
1. Any automated scripts or tools available for this.
2. Challenges and issues... (5 Replies)
Hi,
I am trying what the following loop does :
for i in XYZ
do
for j in M1 R1 R2 R3
do
if
then
kList=""
n=1
while
do
kList="$kList $n"
let n++
done
There are a couple of loop as mentioned above for R1.R2.R3. (1 Reply)
Hi all. On X11 I'm on a shell ...shell_1 (/bin/bash). From here I want to open another shell window shell_2 who executes commands like "ls -l" or programs like ". /program"... so the "result" of commands shows in shell_2 window and not in shell_1. Is that possible ? (4 Replies)
Hi, I am trying to do this thing useing my shell bash ( sorry for my english )
I have in a file 63 hostnames, i wanna ask to the DHCP admin, to reserv that reserves 63 IP addresses of this hosts, using their mac address.
I have thinked this script:
for ((i=1;i<63;i++)); do
arp $(head... (10 Replies)
I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config.
I am not sure if I can do this with BASH scripting.
I have set up password less login by adding my public key to authorized_keys file, it works.
I am a little... (1 Reply)
Hello All,
After login to the server we are explicitly calling /usr/local/bin/bash to activate bash shell properly.
But since commands are not executing properly so I think it is not initialized well. I am facing following problems:
1) If I want to have a look on a particular file using tail... (6 Replies)
I am doing this simple script using c shell and korn shell. The commands I use are fgrep , ls, and also some redirecting. Is there any difference in using both of these commands in c shell and korn shell? Thanks and sorry for the stupid question. (1 Reply)
Everything else seems to be working, but this isn't. Is it the "cat..." that is wrong of the condition? Thanks.
cat tc_result.txt | while read LINE
do
if
then
let "files_run += 1";
echo "inside the if loop"
# save current filetype
case $LINE... (5 Replies)
I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server..
I have seen some code that may help - but I cant get it working as below:
spawn /usr/bin/ksh
send "telnet x <port_no>\r"
expect "Enter command: "
send "LOGIN:x:x;... (2 Replies)