Why Does Command Run From Prompt But Not From Script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why Does Command Run From Prompt But Not From Script?
# 1  
Old 09-17-2008
Why Does Command Run From Prompt But Not From Script?

I hope someone can shed any light on this mystery.

I am trying to run the following command:
su userID -c
remsh server -l userid -n "awk -F^ '\$4 == \"SMITH\"' /tmp/infromational/version74b/LIVE/TEMPORARY/ABCfiles/HLC_Database_File.bat|head -1" > /tmp/variant/45BV32/var/store13.logfnd


I know it's rather long but when I copy/paste it into a command line it runs great. But if I paste the same command into a file and run it as a script it never finishes and I have it hit CTRL +C to break out of it.

Does anyone have any idea why it works one way, but not the other?
# 2  
Old 09-17-2008
Update: I also tried adding #!/bin/ksh or #!/bin/sh to the script, but that didn't change the outcome either. The script still continues to hang and never finish. Smilie
# 3  
Old 09-17-2008
Try putting full path to the commands.

instead of:

su userID -c

try

/usr/bin/su userID -c

Not just for su but for all the commands in the line.
# 4  
Old 09-17-2008
Quote:
Originally Posted by Ikon
Try putting full path to the commands.

instead of:

su userID -c

try

/usr/bin/su userID -c

Not just for su but for all the commands in the line.
Thanks for the suggestion Ikon. I tried it but it didn't work.
# 5  
Old 09-17-2008
How about putting echo statements every other line, so you know where it's failing?
# 6  
Old 09-17-2008
Quote:
Originally Posted by ShawnMilo
How about putting echo statements every other line, so you know where it's failing?
Thanks for the suggestion Shawn but there's only two lines and those lines are static (no variables, etc) so echoing them would not show anything different then what is already in the script.
# 7  
Old 09-17-2008
If it is "hanging" it is probably waiting for a response to the "Password:" prompt. Are you running the script as the root user?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script not working but command works in command prompt

Hi everyone I have a problem with my script If I try directly this command /usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz It works But if I simply add this command in a script and... (8 Replies)
Discussion started by: picemma
8 Replies

2. Shell Programming and Scripting

Shell script prompt for first parameter ($1) then run

I have to run post configuration script like this script file is post_config.sh post_config.sh 1234 #1234 is node ID according to given node ID all script run .. .. But i want to post_config.sh script should ask for node ID then run like this.. post_config.sh #i want to run... (8 Replies)
Discussion started by: Ganesh Mankar
8 Replies

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

Use Unix shell script to open Windows command prompt (cmd)

Hello, I work on Windows and I use Putty to access a remote UNIX server. I am trying to build a shell script that will have as main task to open the Windows command prompt (cmd) and run some Windows commands thereafter. The commands are actually file transfer commands that will download a file... (14 Replies)
Discussion started by: rookie2785
14 Replies

5. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

6. AIX

Command behaves different in script and on prompt

$cat /tmp/tuxob.lst udi ***** jim 10 ant 19 ibm ***** $ input=`head -1 /tmp/tuxob.lst | awk '{print $NF}'` $ echo $input The output I am expecting is '*****'. But It is showing me the available files of current directory. When I run the command head -1 /tmp/tuxob.lst | awk '{print $NF} ... (3 Replies)
Discussion started by: panchpan
3 Replies

7. Shell Programming and Scripting

script submitted using ssh does not return to command prompt

Gurus, I have written a shell script to backup a database and applications. This is how the script works: 1. As applications user (say applmgr), the main backup script, say backup.sh, is kicked off. 2. backup.sh does ssh to oracle user and kicks off the database backup using nohup and... (1 Reply)
Discussion started by: sunpraveen
1 Replies

8. UNIX for Dummies Questions & Answers

running command prompt executable file in shell script

hi i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script example: file name is test.vbs which contains strSoundFile = "C:\windows\Media\Notify.wav" Set objShell = CreateObject("Wscript.Shell") strCommand... (5 Replies)
Discussion started by: atl@mav
5 Replies

9. Shell Programming and Scripting

Command prompt from within a script?

I am writing a menu script and one of the options is to access a Command Prompt and return to the menu via CTRL-D. I have tried using a loop and echoing the PS1 value, then using read to assign whatever is entered into a variable, then executing the value of that variable as a command using .... (1 Reply)
Discussion started by: sanitywonko
1 Replies

10. Shell Programming and Scripting

script to go to a different dir to run a commandline prompt in that dir

Hi, I need to know how I'll be able to write a script that can goto a different dir where I don't have access to read,write and execute and also to run a commandline prompt in that dir with one file whose path has to be specified in that command. Will I be able to do this? Any ideas or... (2 Replies)
Discussion started by: ann_124
2 Replies
Login or Register to Ask a Question