Trying to run a script that runs another script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to run a script that runs another script
# 1  
Old 04-07-2017
Trying to run a script that runs another script

So I have a bash script called count.sh

This is what is inside it-

Code:
if [ -z "$2" ]; then
     echo "Error"
else
     echo "Correct!"

I want to put this script into another script that I'll call parent.sh. However, the issue I'm having is that this count script requires the user to input parameters on the command line. I want this parent script to first prompt the user, and then run the count script. This is what is inside my parent script at the moment-

Code:
echo "Please enter two parameters: "
read input
./count.sh "$input"

I try to run my parent script but no matter what I input it'll always echo out "Error" even if I am putting in two parameters.

Can someone help me fix this? And in a way where I don't edit my count script?

Note: I do not work for a company or project, and I'm simply just learning bash

Last edited by jim mcnamara; 04-07-2017 at 08:20 PM..
# 2  
Old 04-07-2017
Code:
./count.sh  $input

No quotes around $input
# 3  
Old 04-07-2017
Thank you, it works!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with how to run multiple script with concurrent processes runs sequentially.

Hi, The problem detail is follows I have three individual scripts . SCRIPT A sh -x sqoop_channels_nc_daily_01.sh & sh -x sqoop_channels_nc_daily_02.sh & sh -x sqoop_channels_nc_daily_03.sh SCRIPT B sh -x sqoop_contacts_nc_daily_01.sh & sh -x sqoop_contacts_nc_daily_02.sh & sh -x... (1 Reply)
Discussion started by: H_bansal
1 Replies

2. Shell Programming and Scripting

Script runs but does not execute rm -rf command

Hi! First off I'm no bin/bash script writer! :( I can make heads and tales of it from the php experience I have and that's all. Now I managed to piece this script together to go look at directory and remove files that are +60 days. It's finding the files but its not removing them. I... (11 Replies)
Discussion started by: MrBiggz
11 Replies

3. AIX

Script runs in shell but not cron

We run some menu driven software that has the ability to batch menu paths and generate reports quickly. Normally you run a batch like: $ BATCH BATCHNAME The batch program then prompts you for the date you want the report run for. I got some help from some folks on IRC to do the following: BATCH... (2 Replies)
Discussion started by: herot
2 Replies

4. UNIX for Dummies Questions & Answers

Script only runs as a particular user

Hi guys So I've got this PERL script that for one reason or another I need to run as a user other than the user that created the script. When I su - to another user the script won't run and doesn't give me any output as to why. No permission denied or anything like that. I've chmod 777'd the... (5 Replies)
Discussion started by: Jaymoney
5 Replies

5. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

6. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies

7. Shell Programming and Scripting

Shell script which runs sql script

Hi all, I need a shell script which runs a sql script but I couldn't find how to finish it. This is the code that I have: #! /usr/bin/ksh export SHELL=/bin/ksh export ORACLE_SID=database export ORACLE_HOME=/opt/oracle/product/9.2.0.8 sqlplus user <<EOF @/path/path/path/scriptname.sql... (3 Replies)
Discussion started by: Geller
3 Replies

8. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

9. UNIX for Advanced & Expert Users

My script runs too slow :-(...

Hello experts, I have a series issue in script that result with bad peformence and I wonder if you can assist me. For example I have two files: File-New, size 15Mb. File-Old, size 1Mb. File-New content: a b c k File-Old content: d f a b (0 Replies)
Discussion started by: roybe
0 Replies
Login or Register to Ask a Question