Create directories in stagging and informatica server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create directories in stagging and informatica server
# 22  
Old 03-06-2012
Your script can't read from stdin. That's already being used to feed in the script, so your read commands eat part of the script.

Pass in variables into it like I showed you instead. They will be $1, $2, etc.
# 23  
Old 03-06-2012
i tried this .. not sure if i followed u correctly.. or missing something.
Code:
case $Env in
        1)         export Env=devl
            export User=ecifetld
            # mkproj_dirs "/webdata/ecif/etl/$Env/$projectname/"
            export Env=$1
            export projectname=$2
            ssh $User@boom.nwie.net exec /bin/bash -s "'$1'" "'$2'" < mkdir_infor.sh

Got same error ... pls advice

Last edited by Scott; 03-07-2012 at 11:21 AM.. Reason: Code tags
# 24  
Old 03-06-2012
Why do you have ssh inside the script when you're running this script on another server? I think you've gotten very confused along the way. Do all the ssh-es on the local side.

That's why I suggested doing what I did originally.

Code:
ssh username@host mkdir "'/path/to/whatever'" ';' tar -C "'/path/to/whatever'" -xf - < file.tar

Run that locally to create directories on the remote host. That should be all you need.
# 25  
Old 03-06-2012
i am running script mkdir_infor.sh on remote server .Do you want me to copy this script on remote server to create the directories .. It would like copying script on env servers..
Any other suggestions..!
Thanks
# 26  
Old 03-06-2012
Is it really your intent to ssh from server A into server B, so that server B can ssh into server C, to create directories on it? Why not just ssh into server C in the first place? Smilie

I think you've misunderstood the purpose of what I've suggested. You need to run these things on the local host. It makes no sense to run them anywhere but the local host. These commands log into the remote host and to the job you asked for -- creates directories on the remote host. By just dumping parts of what I've shown you in the middle of a script to be run on the remote host you're really changing the meaning of it.

I've shown you what you need to do. It's not an element of something you need to run anywhere else. It ought to work when run on the local host, allowing you to create directories on the remote host, as long as you've created a tar file like I illustrated earlier.

Code:
# Run this on the local host, to log into username@host and create directories in /remote/path/$ENV/whatever
ssh username@host mkdir "'/remote/path/$ENV/whatever'" ';' tar -C "'/remote/path/$ENV/whatever'" -xf - < ~/file.tar

Have you tried it yet? Not as part of a script, not sending it to the remote host, not anything but running this exact line on the local host with the paths you want on the remote host.

Does it work? Yes or no?

If not, in what way?

Last edited by Corona688; 03-06-2012 at 06:01 PM..
# 27  
Old 03-07-2012
I intent to ssh server B from Server A and then create directories in server B.

---------- Post updated at 11:28 AM ---------- Previous update was at 10:15 AM ----------

Sorry, But i am not able to understand the code u suggested .
"# Run this on the local host, to log into username@host and create directories in /remote/path/$ENV/whatever
ssh username@host mkdir "'/remote/path/$ENV/whatever'" ';' tar -C "'/remote/path/$ENV/whatever'" -xf - < ~/file.tar"

Last edited by nitinmathur18; 03-07-2012 at 12:24 PM..
# 28  
Old 03-07-2012
Quote:
Originally Posted by nitinmathur18
Sorry, But i am not able to understand the code u suggested .
"# Run this on the local host, to log into username@host and create directories in /remote/path/$ENV/whatever
ssh username@host mkdir "'/remote/path/$ENV/whatever'" ';' tar -C "'/remote/path/$ENV/whatever'" -xf - < ~/file.tar"
It runs two commands on the remote server.

1) mkdir /remote/path/$ENV/whatever
2) tar -C /remote/path/$ENV/whatever -xf - < ~/file.tar

They are separated by ';', which will be fed into the other end as simply ;, as a separator between two shell statements. If you didn't put quotes around it, your shell would attempt to run tar on localhost instead of feeding the command into ssh...

The 1) command creates the base directory you want.

The 2) command extracts the tarball you made, of all the subdirectories with the permissions you wanted, inside /remote/path/$ENV/whatever. It reads from standard input.

~/file.tar, a file on the local host(not the remote host!), is the tarball I showed you how to create before. It is redirected into the standard input of ssh, so tar on the other end can read it from its own standard input without having to keep the file on the remote host.

All you have to do is substitute your own variables and filename into it, then run it locally.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to create automated Directories

Hi, On serverB i wish to have a script that creates ONLY & EXACTLY the same folder structure that i provide on ServerA. Thus if serverA has a folder "Output" under /opt/app/Output and has the below folders under Output Output Output/logs Output/reciever Output/data... (11 Replies)
Discussion started by: mohtashims
11 Replies

2. UNIX for Dummies Questions & Answers

Create 2 directories in one command

Hi how can i create 2 directories in two different directories ($HOME and $PWD) with 1 command? dir 1 in $HOME and dir2 in $PWD (2 Replies)
Discussion started by: chinababy
2 Replies

3. Shell Programming and Scripting

Create duplicate directories with same permissions

Hi all, I need to create duplicate directories and sub directories (only the directories not the files or file contents) with the same permissions. Can some one guide me in doing this. I could able to create but here the permissions should be the same how can i do this in linux. Thanks in... (5 Replies)
Discussion started by: Olivia
5 Replies

4. Shell Programming and Scripting

UNIX script to check file and start the informatica server

Hi Rockers, I hope u r dng good one. I have a one question is in unix with informatica . I need a unix script to check whether particular file exists in the folder , If it means we have a informatica server , so we can start the informatica server by accessing that file. Every week we have... (0 Replies)
Discussion started by: gurukrishnan
0 Replies

5. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

6. UNIX for Dummies Questions & Answers

Want to create 3 different new directories under the same path

Hi, Iam new to UNIX...My requirement is to create 3 dir as an hierarchy under /var/opt/temip.The output should be /var/opt/temip/GP_Int/GPTTS/AUTO. I have tried the following script...But only GP_int folder is getting created and not other folders...Can someone help??? #!/usr/bin/ksh #script... (1 Reply)
Discussion started by: Llb
1 Replies

7. UNIX for Dummies Questions & Answers

How to create shotcuts to the directories

Hi, I need your help in writing shortcuts to my directories. So that I can go into the directories with the help of shortcuts. For example: there is a directory called /home/java/webapps/project1 I want to give a shortcut as project1 . So whenever I have give cd project 1 from command line ... (3 Replies)
Discussion started by: TonySolarisAdmi
3 Replies

8. UNIX for Dummies Questions & Answers

copying directories from NT server to Unix server (solaris 5.8)

I need to copy around 30 directories (each directory include one or more text file(s)) from NT server to Unix server at one go. For doing this what are the privillages i should have in both NT and Unix server. Please let me know which command i can use in shell prompt. TIA. (4 Replies)
Discussion started by: jhmr7
4 Replies

9. Programming

Using a C program to create directories in UNIX

Aloha, I'm attempting to use a C program to create directories and then use a system call to have another program write .dat files into that directory. I understand that I could use the "system("mkdir directory_name")" function however, I would like my program to create a new directory each time... (3 Replies)
Discussion started by: aloha_boi
3 Replies

10. UNIX for Dummies Questions & Answers

How to create directories

Hi... Can any1 help me by telling me the way to create multiple directories using single command.... to create 1 directory.. mkdir is used.... :D but how to create multiple direcs. like 4 direc. i tried .... $ mkdir a; mkdir b; mkdir c; mkdir d But its 4 commands in a single... (3 Replies)
Discussion started by: abishekmag
3 Replies
Login or Register to Ask a Question