Issue with the shell script after storing the directory in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue with the shell script after storing the directory in a variable
# 1  
Old 05-04-2016
Issue with the shell script after storing the directory in a variable

FTP is connecting to the server but i am getting an error -

Code:
Enter if the env is dev or test or prod:
test
Please enter the id no :
xxxxxxx
Connected to xxxx
220 (vsFTPd 2.2.2)
331 Please specify the password.
230 Login successful.
?Invalid command
?Invalid command
?Invalid command
?Invalid command
?Invalid command
200 PORT command successful. Consider using PASV.

Below is shell script -

Code:
#!/bin/bash
echo "Enter if the env is dev or test or prod:"
while :
do
read -r INPUT_STRING
case $INPUT_STRING in
        test | TEST)
                                echo "Please enter id no : "
                                read -r input_variable
                                if [[ ${#input_variable} -ne "7" ]]
                                then
                                echo "Please check id no given"
                                exit 1
                                fi
                                HOST=XXX
                                USER=XXX
                                PASSWORD=XX
                                ftp -inv $HOST <<- EOF
                                user $USER $PASSWORD

                              mypath='/test/$input_variable/destination/'
                                if ! cd "$mypath"
                                 then
                                 exit 1
                                fi
                                mput x.csv
                              EOF
                              exit 1
                                ;;
esac
done

Moderator's Comments:
Mod Comment Please post in the correct forum!

Last edited by RudiC; 05-04-2016 at 05:26 AM.. Reason: Scrutinizer: code tags / RudiC: moved to correct forum.
# 2  
Old 05-04-2016
I don't think ftp has the if ... then ... fi construct.
# 3  
Old 05-04-2016
Quote:
Originally Posted by chandraprakash
FTP is connecting to the server but i am getting an error -

Please try to execute the script in debug mode and share the o/p.

Code:
sh -x <script_nm.sh>

...and RudiC is correct.
# 4  
Old 05-04-2016
Quote:
Originally Posted by saps19
[..]
Code:
sh -x <script_nm.sh>

[..]
Note: since the shebang says it is a bash script, that should be
Code:
bash -x script_file

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

2. Shell Programming and Scripting

Storing filenames in an array in shell script

hi, i am writing a shell script in which i read a line in a variable. FNAME="s1.txt s2.txt s3.txt s4.txt s5.txt" i want to create a array and store single file names in a array.. so the array should contain arr="s1.txt" arr="s2.txt" arr="s3.txt" arr="s4.txt" arr="s5.txt" how to... (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

Storing a directory as a variable in KSH

I know this is sort of trivial, but basically I want to store a directory as a variable in KSH so I can later call it. I am not sure if the syntax is right: DIRECTORY={/abc/domain/${DIV}/} where DIV is another variable. Thanks! (1 Reply)
Discussion started by: MIA651
1 Replies

4. Shell Programming and Scripting

sed not storing output in shell script

Hello, Following my learning of shell scripting.. I got stuck yet again. If I execute this command on terminal: $ sed "s/off/on/g" file > fileAUX I successfully change the text off to on from file to fileAUX. But the same command is not working inside a shell script. I tested and... (2 Replies)
Discussion started by: quinestor
2 Replies

5. Shell Programming and Scripting

Problems with storing oracle sqlplus query output shell script

Hello everyone, I have a RHEL 5 system and have been trying to get a batch of 3-4 scripts each in a separate variables and they are not working as expected. I tried using following syntax which I saw a lot of people on this site use and should really work, though for some reason it doesn't... (3 Replies)
Discussion started by: rockf1bull
3 Replies

6. Shell Programming and Scripting

variable issue in a bash in a shell script

Hi, I am trying to write a PBS shell script that launches a bash process. The issue is that the bash process needs a variable in it and the shell script is interpreting the variable. How do I pass this as a literal string? Here is my code snippit: TMP=".fasta" FILEOUT=$FILE$TMP cd... (2 Replies)
Discussion started by: bioBob
2 Replies

7. Shell Programming and Scripting

Issue with passing variable to Grep in a shell script

Hi, I'm trying to check if methods specified in a class have been added to the corrosponding interface. My code below is giving me the following errors: grep: function: No such file or directory grep: import($zipfile): No such file or directory grep: function: No such file or... (1 Reply)
Discussion started by: racshot65
1 Replies

8. UNIX for Dummies Questions & Answers

Storing values in shell variable

Hi, I am writing a shell script where, x=y y=z When I want to print z, I can do $y How do I use only "x" without any direct reference to "y" to print z? Thanks, -G (3 Replies)
Discussion started by: gaurab
3 Replies

9. UNIX for Dummies Questions & Answers

Storing lines of output into a script variable

I'm sure this is a simple thing but I can't figure it out. In a script that I'm writing, I'd like to be able to store each line of output from "ls -l" into a variable. Ultimately I'd like to end up with something like: for a in `ls -l` do something with $a doneBut that's reading each... (2 Replies)
Discussion started by: ewoods
2 Replies

10. Shell Programming and Scripting

Storing the values in text file using while loop in shell script

Hi Frdz while read line do name=`echo $line | cut -d' ' -f 1 ` password=`echo $line | cut -d`-` -f 2` name > logfile.txt password > logfile.txt done < list.txt When it is run, am getting last values in list.txt file only,it is not storing lall the list entry values. How can i... (5 Replies)
Discussion started by: KiranKumarKarre
5 Replies
Login or Register to Ask a Question