Text file location and its data check at FTP server in informatica - informatica

How to check in informatica whether a flat file exists at a location at FTP server and to check if it has some data in it?

One solution is to create Windows or Unix shell script on the Informatica server that checks for the existence of the file.
Something like this:
#!/usr/bin/ksh
if [ ! -f /Filelocation/INPUT_FILENAME.txt]
then
echo "Source not found"
exit 1
else
echo "Source present"
exit 0
fi
done
exit 1
Create a command session in Workflow that runs this script.

Related

how to send a mail when workflow not triggered at given time in informatica

I have a workflow which gets triggered everyday in the Morning at 07:15 AM.I want to get an email to my Id from Informatica when the workflow doesn't get trigerred within 3 min from the start time.
You have two options -
easiest would be - create another workflow(scheduled at 7:18 AM) with a command task which will check a file.
After command task, put a condition to the task link status=1 and then add a email task.
Add a touch command as pre session to the main workflow.
New workflow will be like -
start -->cmd task -->|--link status<>0--> email task
command task will be like -
#!/bin/sh
if [ -r /somedir/ind.txt ]; then
exit 0
rm /somedir/ind.txt
else
exit 1
fi
Now, in real time, at 7:15 the wkflow will start and crete the file, second workflow will detect and do nothing. Now , if file doenst exist, it will mail.
second option will be, you can create a cron script that starts around 7:18AM, check if file exist or not - if file is absent, it will mail and delete the file. Your command file should be like this -
#!/bin/sh
if [ -r /somedir/ind.txt ]; then
exit 0
rm /somedir/ind.txt
mail -s <...some command...>
else
exit 1
fi

How to make blocking AWS CLI calls

Most of the AWS CLI calls are asynchronous.
Therefore, after you call them, you have no idea if end product was successful or not.
Is there a simple solution for, checking if environment was created successfully, as an example, other than creating timed polling verification calls, etc etc.
Sorry I did not mention previously, but I am specifically looking for solutions from Powershell
You can check the Exit Status for cli command.
What is an exit code in bash shell?
Every Linux or Unix command executed by the shell script or user has
an exit status. Exit status is an integer number. 0 exit status means
the command was successful without any errors
code snippet:
aws cli command
if [ $? -ne 0 ]
then
echo "Error"
exit 1;
else
echo "Passed"
fi
another method is to wait for a response from the command :
while :
do
sleep 10
echo "Waiting for elasticsearch domain endpoint..."
local ELASTICSEARCH_ENDPOINT=$(aws es describe-elasticsearch-domain --domain-name ${ES_DOMAIN_NAME} --region ${AWS_REGION} --output text --query 'DomainStatus.Endpoints.vpc')
if [ ${ELASTICSEARCH_ENDPOINT} != "null" ]
then
echo "Elasticsearch endpoint: ${ELASTICSEARCH_ENDPOINT}"
break
fi
done

How to set $HOME before startup script in Google Compute Engine

In my use case, I am trying to use the $HOME variable to identify my app server path in the instance startup.
I am using Google compute engine with a startup script which uses $HOME variable. But it looks $HOME is not set or the user is not created while startup script executes in google cloud.
It throws $HOME not set error. Is there any workaround for this? Now I have to restart the instance after creating for the first time. So that the $HOME variable will be set when I restart. But this is an ugly hack for production.
Could someone help me with this?
The startup script is executed as root when the user have been not created yet and no user is logged in (you can check it running at startup $ users and comparing the output of $ cat /etc/shadow after a reboot).
Honestly I don't understand how just a reboot can make your $HOME be populated at startup time since on Linux, the HOME environment variable is set by the login program:
by login on console, telnet and rlogin sessions
by sshd for SSH
connections by gdm, kdm or xdm for graphical sessions.
However if you need to reboot and you don't want to do it manually you can reboot just once after the creation of a machine:
if [ -f flagreboot ]; then
...
your script
...
else
touch flagreboot
reboot
fi
On the other hand if you know which is going to be the $HOME path of your application you can think to simply export this variable at startup to populate it manually.
$ export HOME=/home/username
printenv
cd $HOME
touch test.txt
echo $HOME >> test.txt
echo $PWD >> test.txt
printenv > env.txt
I included the above code in my startup script. Strangely, the $HOME, $PWD and many other environment variables are not set while the startup script is runninng. Here are the contents of of the files I created during the startup.
test.txt:
/
env.txt:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/
LANG=en_US.UTF-8
SHLVL=2
_=/usr/bin/printenv
Here's the output(some values removed) of printenv command, immediately after the VM creation.
XDG_SESSION_ID=
HOSTNAME=server1
SELINUX_ROLE_REQUESTED=
TERM=xterm-256color
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=
SELINUX_USE_CURRENT_RANGE=
SSH_TTY=/dev/pts/0
USER=
LS_COLORS=
MAIL=/var/spool/mail/xyz
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/*<username>*/.local/bin:/home/*<username>*/bin
PWD=/home/*<username>*
LANG=en_US.UTF-8
SELINUX_LEVEL_REQUESTED=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/*<username>*
LOGNAME=*<username>*
SSH_CONNECTION=
LESSOPEN=||/usr/bin/lesspipe.sh %s
XDG_RUNTIME_DIR=/run/user/1000
_=/usr/bin/printenv
To summarize, not all the environment variables are set at the time the startup script executes. They are populated some time after. I find that wierd, but that's how it's works.

How to use autofs to mount an NFS share on IPA server

I have an IPA Server and client set up, with NFS and autofs installed on both. Whenever I make a user with ipa user-add, and then I switch to that user, IPA creates a home directory for that user and displays Creating home directory for user. I want to make it so autofs sets up the home directory instead, so that IPA does not need to. My IPA server also acts as an NFS server and I added /home into my /etc/exports and pointed it to my client machine. My IPA client serves as my NFS client and it has /home mounted on /mnt/nfs/home. On my client I went into /etc/auto.master and added a line /home /etc/auto.misc. Then I added onto /etc/auto.misc with the line:
* -fstype=nfs :nameofserver.example.home:/mnt/nfs/home. After all that, I restarted autofs and tried making a user but when I switch to the user now I get the message warning: cannot change directory to /home/user: No such file or directory What am I doing wrong?
The IPA configuration of autofs make that the user home is mounted not the root of user home. That means in your case that the autofs is trying to mount /mnt/nfs/home/newuser.
AFAIK they are no official workaround with this chicken/egg problems. Free-ipa is currently working on a hook/callback systeme that is supposed to provide a solution to that old and well know "problematic".
Since this update was'nt available yet, the only know way is to setup a cron script that make call to the LDAP service of the IDM server and create the new home. But no one seens to have release a code to do so.
Here is the bash script I have made for this purpose. I ran it in a cron set to each minutes.
#!/bin/bash
TIMEFILE=/root/scripts/data/ldap_last_check.txt
LASTTIME=$(cat $TIMEFILE)
CURRENTTIME=$(date +%Y%m%d%H%M%SZ)
echo $LASTTIME
NEWUSERLIST=$(/usr/bin/ldapsearch -LLL -x -h localhost -b "cn=users,cn=accounts,dc=domain,dc=com" "(createTimestamp>=$LASTTIME)" uid)
UID_REGEX="^uid:"
mount filesrv:/srv/idmhome /mnt/idmhome
OLDUSERLIST=$(ls -1 /mnt/idmhome)
while read -r i_line; do
HOME_EXIST=false
if [[ $i_line =~ $UID_REGEX ]]; then
TMPUSER="$(echo $i_line | awk '{print $NF}')"
while read -r j_line; do
if [[ $TMPUSER = $j_line ]]; then
HOME_EXIST=true
fi
if [[ $TMPUSER = "admin" ]]; then
HOME_EXIST=true
fi
done <<< "$OLDUSERLIST"
if ! $HOME_EXIST; then
mkdir /mnt/idmhome/$TMPUSER
cp /etc/skel/.* /mnt/idmhome/admin/
chown -R $TMPUSER:$TMPUSER /mnt/idmhome/$TMPUSER/
ls -lah /mnt/idmhome/$TMPUSER
fi
fi
done <<< "$NEWUSERLIST"
umount /mnt/idmhome
echo $CURRENTTIME > $TIMEFILE
My setup is a little bit different than your, my nfs server is'nt on the same server as my IDM. You just have to comment the mount/umount line and change path to yours and it's should work fine.
consider to make a similar code to erase/archive deleted account.

'Execute Command' keyword does not complete the execution on remote machine

I am trying to run a command (Jar file execution) on a remote machine using the 'Execute Command' keyword of SSH library. But the control returns even before the command execution is completed. Is there a way to wait until the command is executed?
Below are the keywords written:
Run The Job
[Arguments] ${machine_ip} ${username} ${password} ${file_location} ${KE_ID}
Open Connection ${machine_ip} timeout=60
Login ${username} ${password}
${run_jar_file}= Set Variable java -jar -Dspring.profiles.active=dev ${file_location} Ids=${KE_ID}
${output}= Execute Command ${run_jar_file}
Log ${output}
Sleep 30
Close Connection
Use Read and Write, instead of using "Execute Command" so that you can specify timeout for command execution.
refer: http://robotframework.org/SSHLibrary/latest/SSHLibrary.html#Write
You are explicitly asking for the command to be run in the background (by virtue of adding & as the last character in the command to be run), so the ssh library has no way of knowing when the program you're running exits. If you want to wait for it to finish, don't run it in the background.
In other words, remove the trailing & from the command you are running.
If anyone is still strugling with this one, i have discovered solution
Open Connection ${SSH_HOST} timeout=10s
Login login pass
Write your_command
Set Client Configuration prompt=$
${output}= Read Until Prompt
Should End With ${output} ~ $