I need a help on my shell script. Below is my shell script which transfers the file from one server to another.
The shell script is working fine and it is copying the file X.csv once we enter id no which is present in remote server. However I have certain issues which is listed below -
1.id no should be of 6 characters (like M000001).
2.When I enter the correct id, the script is copying the file.However when i enter wrong id eg. M000050 which is not present in remote server, then also it is showing the file is copied. But I don't have any idea where it is copying the file.
3.I need to create the directory /final/ if it doesn't exit in remote machine. the path till inputs will be present in remote server.
Last edited by RudiC; 05-02-2016 at 07:24 AM..
Reason: Added code tags (AGAIN!)
1) The id no. shown is 7 chars in length. Do you just need to test on its length or also impose some structure (like "start with an upper case "M")?
2) It will copy to/wpath/to/copy/files//inputs/final/ and return an error if that is not available. The double slash will be interpreted as a single one on most systems. Do you have a list of allowed target directories present on the local node?
3) Use ftp's mkdir command.
Pertaining to your problem at hand you already got some sound advice.
Anyways, i would like to question your construction as a whole:
Quote:
Originally Posted by chandraprakash
I need a help on my shell script. Below is my shell script which transfers the file from one server to another.
I think you should not use ftp any more and you definitely should not put passwords into scripts AT ALL!
You can do all you have shown here using either "sftp" or - IMHO even better - "scp" and avoid many of the obstacles you try to overcome from the beginning.
What you need for "scp" to work is an installed "ssh" suite (scp is usually part of this) and exchanged keys. How to do that, how to generate the keys and store them in the appropriate key files is described in many threads here, just search for it.
Having set up this here is the sketch of a script you could use:
Of course you can put a lot more testing into this sketch, create better error-handling, maybe test for the IP-connectivity first before trying the ssh-connection (ping), etc.. Scripting is not about doing things but to plan in advance what possibly could go wrong and cover for that.
Hi there
please have a look at the code..i want to create Using a named pipe. Run a find in the background starting in the working directory
While this is happening wait for input from the user to ask him which file to find.
If the user does not enter any data in 10 seconds ask the user again.... (1 Reply)
Hi, if in a network there are lots of PCs connected with either windows or linux as operating system.Then what will be the shell script for the same and also if the PC has linux in it then we have to find if it is occupied or unoccupied.
If the PC has windows in it then we have to find if it is... (6 Replies)
Hey I have a data in the file named as outputFile.txt. The data is in the format
123456,12345678912345,400,09/09/09,INACTIVE.
I want this output without commas ie
12345612345678912345400090909INACTIVE.
Please tell me what to do and clear explain all the terms, as I am new to it. (6 Replies)
Gents,
I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)