Passing value to an external program problem...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing value to an external program problem...
# 1  
Old 08-15-2005
Passing value to an external program problem...

This code is in my 'case' statement and it all else works fine.

The problem I have is that the value in 'procno' is not passed on to the external program (fireit).
It is passing all zeros instead of the actual process number.

By the time I get to this case statement, I know the "Number" and "Proc".
I then set procno variable to 'Number' and procname to 'Proc' in this 'case' block:
.
.

*)
procno=$Number
procname=$Proc

if [[ $procname = myspecialproc ]]; then
echo "Skipping this process."
else
echo "Kicking off process $procname ProcessID #$procno..."
# pass the procno to external program fireit:

fireit ${procno}

rc=$?
if [[ $rc -eq 0 ]]; then
echo "Process $procname was kicked off, ProcessID is $procno."
else
echo "Process didn't kick off."
fi
fi
etc...

The 'rc' always returns '0' because it is successful kicking off 'fireit'.
However, the log from 'fireit' shows that this script passed in all zeros ('00000')
instead of say, '12345'.

The log looks like this in this script (myscript.ksh):

..
Kicking off process SumResult100 ProcessID # 12345...
Process SumResult100 was kicked off, ProcessID is 12345.
...

fireit log shows:

Sorry. ProcID '00000' was not found.

What's going on???
This is on AIX and using KSH. It seems that myscript is capturing and sending correct number to fireit but fireit sees all zeros and message is displayed exactly as seen on the screen.
Also, I cannot modify fireit, it's an internal program from a third party software, the error log that is captured is seen only on the screen.
If I type "fireit 12345" on the Unix command line, it works but not via this script.

Thanks,

Giannicello
# 2  
Old 08-21-2005
It's pretty weird.
Is there anything else in the script between the lines you have typed? I mean could it be that the variable is not known when fireit is executed.

Why would not you run your script with options "xtrace' and 'verbose' to see what is really running:

ksh -xv myscript.ksh

Then you will see what argument was actually passed to fireit.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Duplicate check by passing external parameter

I have a code which is using to find duplicates in a files based on column.Below is the same code which is used to find duplicates in my file based on column 1 awk -F'|' '{if (x) { x_count++; print $0; if (x_count == 1) { print x } } x = $0}' FileName >Dup_File.txt But my requirement here is... (3 Replies)
Discussion started by: ginrkf
3 Replies

2. Shell Programming and Scripting

Passing external variable to awk

Hi, I am trying to write a bash script in which I need to pass a external variable to the awk program. I tired using -v but it not accepting the value. Here is my sample code. #!/usr/bin/bash ###################################################################################### ####... (5 Replies)
Discussion started by: jpkumar10
5 Replies

3. Shell Programming and Scripting

Problem in passing date to external function from perl script.

my $sysdate = strftime('%Y-%m-%d', localtime ); biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals) In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
Discussion started by: Devesh5683
1 Replies

4. Shell Programming and Scripting

passing file extension using external variable

Hi, How can I modify the FILETYPE command ? I want to provide the file extension, like txt, root .? Thanks, #!/bin/bash FROM=$1 TO=$2 FILETYPE=$3 ... (4 Replies)
Discussion started by: nrjrasaxena
4 Replies

5. Shell Programming and Scripting

how to invoke external program and capture its output

Hi all, I am using an external binary to view memory starting from a specific address and i want to automate this via PERL however there are problems. Hope you can help me ..thx The output of the programme is like below: bash-3.2$ mem_disp 12B21D20 100 Opening RO Data Memory File scp.ro... (4 Replies)
Discussion started by: ekckabatop
4 Replies

6. Shell Programming and Scripting

For loop to run external program

Hi, I was hoping for help with a for loop to run a program (vina) repeatedly using all the files in a folder as input. Currently my code looks like this: #!/bin/bash FILES=/home/afalk/Desktop/battest/*.pdbqt for f in $FILES do vina --config /home/afalk/Desktop/A.txt --ligand "$f".pdbqt done... (5 Replies)
Discussion started by: oldmanwinter
5 Replies

7. Shell Programming and Scripting

passing arguments to external script

Hi! I have a python script that requires arguments and these arguments are file paths. This script works fine when executed like this: /my_python_script "file_path1" "file_path2" (i added quotes as some file names may have weird characters) the issue happens when i launch my python script... (14 Replies)
Discussion started by: gigagigosu
14 Replies

8. Shell Programming and Scripting

Passing answers to external program from KSH

I have asked this before but I haven't had any luck so far getting this to work. I use RCS(revision control system). When it runs if I pass the value 'unlock' to $3 its reassigned to $unlock. When I run the command (rcs -u'version number' 'filename') ti will ask me 1-(Do you want to break the lock... (5 Replies)
Discussion started by: pjones006
5 Replies

9. Programming

Run external program in background

Hi, in my program i need to run an external program in background.I am aware that there are at least 2 alternatives for this: 1)fork+exec 2)system("program &"); I have read several posts about this,and they all tend to suggest to use fork+exec (and that's what i am doing now). I have some... (2 Replies)
Discussion started by: Zipi
2 Replies

10. Programming

Problem with external program launch

Hello, in the application i'm writing i need to launch "recordmydesktop" to capture the screen,but i'm having a problem: when the recording stops,and the encoding of the saved file starts,the entire system hangs until the completion of the encoding.This happens if i launch recordmydesktop from my... (7 Replies)
Discussion started by: Zipi
7 Replies
Login or Register to Ask a Question