summaryrefslogtreecommitdiff
path: root/convert.sh
blob: 30436ad2a8f00a4d159705db97572c5be0ec6068 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

#Log file location
log="/var/log/psicekicad.log"

echo "###########Start Conversion from PSPICE to KICAD#################" >> $log
echo "" >>$log
echo "The Conversion starts at `date`" >> $log
####Getting Parameter
convertedSchematic=$1 
filepath=$2 
username=$3 
cwd=`pwd`

echo "">>$log
echo "The paramters to the script is : ">>$log
echo "File : $filepath">>$log
echo "Username : $username">>$log
filename=`basename $filepath`
filewithoutExt="${filename%.*}"

echo "File name is : $filename">>$log
echo "File name without extension : $filewithoutExt">>$log
echo "">>$log

#Create Directory for every User

if [ -d $convertedSchematic/$username ];then
    echo "User directory $username is already available">>$log
else
    mkdir -p $convertedSchematic/$username
fi

echo "The converted file will be present at $convertedSchematic/$username">>$log

#Creating directory for uploaded Project
mkdir -p $convertedSchematic/$username/$filewithoutExt

#Converting PSpice to Kicad Schematic
echo "Calling Schematic conversion script" >>$log
/var/www/html/esim_in/sites/all/modules/pspice_to_kicad/schConverter64 $filepath $convertedSchematic/$username/$filewithoutExt/$filename 2>&1>>$log

#Converting to Zip file
cd $convertedSchematic/$username
#sudo zip -rq -rm $zipname $filewithoutExt
echo "Creating zip file of converted project">>$log
zip -r $filewithoutExt{.zip,} 2>&1>>$log
echo "The zip file is present at `pwd`">>$log
cd $cwd
rm -rf $convertedSchematic/$username/$filewithoutExt

echo "###########End PSICE to KICAD Conversion#########################">>$log
echo " ">>$log

exit